L
L
lex2017-01-19 01:40:10
JavaScript
lex, 2017-01-19 01:40:10

How to access the template engine on the client?

Hello, please help me, why I still can’t get bemhtml on the client, everything seems to be ok and the dependencies and everything called. and yes, such a question, if I write everything through bemtree (well, as bemhtml I have purely for tagging and attributes, that is, so far there are only different trifles) and in fact I don’t have a template, I just want to use the template engine itself on the client, which I do not So?

modules.define('manager', ['i-bem__dom', 'BEMHTML', 'menu', 'jquery'], function(provide, BEMDOM, BEMHTML, MenuEvent, $) {

    provide(BEMDOM.decl(this.name, {
        onSetMod : {
          'js' : {
            'inited' : function() {
                MenuEvent.on('update', this._taskUpd, this);
            }
          }
        },
        _taskUpd : function () {
            
            this.setMod(this.elem('content'), 'action', 'artAdd');

            var bemjson = {
                block: 'content',
                content: [
                ]
            };

            var html = BEMHTML.apply(bemjson);

            console.log(html);

            BEMDOM.update(this.elem('content'), html);

            return false;
        }
    }));

});

dependencies
({
  shouldDeps: [
  	{ elem: 'control'},
  	{ elem: 'content'},
  	{ mods: { action: 'article'} },
    { block: 'modal', mods : { theme : 'islands', autoclosable : true }},
    'button',
    'content',
    'menu',
    { block: 'i-bem', elem: 'dom' },
    { tech: 'js', mustDeps: { elem: 'content', tech: 'bemhtml' } }
  ]
})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lex, 2017-01-19
bem @bemdev

[{
  shouldDeps: [
  	{ elem: 'control'},
  	{ elem: 'content'},
  	{ mods: { action: 'article'} },
    { block: 'modal', mods : { theme : 'islands', autoclosable : true }},
    'button',
    'content',
    'menu'
  ]
}, {
    tech: 'js', // зависимости для технологии js
    shouldDeps: [
        {
            block: 'content',
            tech: 'bemhtml' // нужна технология bemhtml
        }
    ]
}]

this is how you need to arrange dependencies, so in the config you can specify the permission of all templates at once.

D
Damir Makhmutov, 2017-01-19
@doodoo

Shouldn't the dependencies look like this?

({
  shouldDeps: [
  	{ elem: 'control'},
  	{ elem: 'content'},
  	{ mods: { action: 'article'} },
    { block: 'modal', mods : { theme : 'islands', autoclosable : true }},
    'button',
    'content',
    'menu',
    { block: 'i-bem', elem: 'dom' }
  ]
}, { tech: 'js', mustDeps: { elem: 'content', tech: 'bemhtml' } })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question