npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dresscode-botex

v0.0.32

Published

Botex написан в методологии DressCodeJS.

Downloads

40

Readme

Botex – шаблонизатор и библиотека для построения UI

Botex написан в методологии DressCodeJS.

Установка

npm i -D dresscode-botex

Версию в package.json после установки желательно поменять на latest. В .dresscode-файлах прописываем путь до библиотеки:

path-to-local-node_modules/dresscode-botex/lib

Использование шаблонизатора

Шаблон – это класс, наследуемый от Botex.Template. У экземпляра класса есть метод _render, который возвращает объект со свойством content, значение которого и является результатом работы шаблона.

var Tpl = Bricks.inherit(Botex.Template, {
    _render: function() {
        return {
            content: 'Hello!'
        };
    }
});
alert(new Tpl());  // Hello!

Шаблон принимает параметры, список которых со значениями по умолчанию описывается в свойстве params. Метод _render принимает предобработанные параметре в первом аргументе.

var Tpl = Bricks.inherit(Botex.Template, {
    params: {
        name: 'World'
    },
    
    _render: function($) {
        return {
            content: Botex.format('Hello, #{0}!', $.name)
        };
    }
});
alert(new Tpl());  // Hello, World!
alert(new Tpl({name: 'Ivan'}));  // Hello, Ivan!
 

Наследование шаблонов

При наследовании шаблонов результат работы дочернего шаблона передаётся на вход родительскому шаблону.

var Tpl1 = Bricks.inherit(Botex.Template, {
    params: {  // этот шаблон принимает два аргумента, эти аргументы мы можем передать из дочернего шаблона. 
        name: 'World',
        age: '14'
    },
    
    _render: function($) {
        return {
            // content на самом деле просто параметр шаблона Botex.Template, родительского для Tpl1
            content: Botex.format('Hello, #{0}! You are #{1}.', $.name, $.age)
        };
    }
});

var Tpl2 = Bricks.inherit(Tpl1, {
    params: {
        firstName: 'Ivan',
        lastName: 'Ivanov'
    },
    
    _render: function($) {
        return {
            // параметра content у Tpl1 нет, поэтому и передавать его бессмысленно. Мы его могли бы передать на уровень выше, для Botex.Template, но Tpl1 его всё равно переопределит.
            name: Botex.format('#{0} #{1}', $.firstName, $.lastName)
        };
    }        
});
alert(new Tpl2({lastName: 'Petrov', age: 26})); // Hello, Ivan Petrov! You are 26.

Шаблон Botex.Tag

Для создания HTML-тегов есть предопределённый шаблон Botex.Tag

Аккумулируемые параметры

По-умолчанию, переопределённые параметры затирают предыдущее значение.

Функция Botex.zen

Интеграция с библиотекой Quantum