bem / bem-xjst

bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server
https://bem.github.io/bem-xjst
Other
116 stars 48 forks source link

Support js() mode for mixes #147

Closed tadatuta closed 7 years ago

tadatuta commented 8 years ago
bemhtml.compile(function() {
    block('b1').js()({ blah: 123  });
    block('b2').js()({ ololo: 'trololo' });
});

bemhtml.apply({
    block: 'b1',
    js: { zzzz: 555 },
    mix: { block: 'b2', js: { qqq: 'qweqwewqeq' } }
});

Resulted with

<div class="b1 b2 i-bem" data-bem='{"b1":{"zzzz":555,"blah":123},"b2":{"qqq":"qweqwewqeq"}}'></div>

but

<div class="b1 b2 i-bem" data-bem='{"b1":{"zzzz":555,"blah":123},"b2":{"qqq":"qweqwewqeq", "ololo": "trololo"}}'></div>

expected.

qfox commented 8 years ago

Why? Do we start executing templates for mixes?

tadatuta commented 8 years ago

@zxqfox https://github.com/bem/bem-core/blob/v2/common.blocks/i-bem/i-bem.bemhtml#L393-L457 ;)

blond commented 8 years ago

@tadatuta how i can replace js mode and ignore input BEMJSON?

arikon commented 8 years ago

Should we run all the templates for the mixes?

qfox commented 8 years ago

@blond There is the same question about tag or even attrs.style.

block('a')(
  tag().force()('qwe'),
  attrs().force().important()(function() {
    return {style: 'font-size: 40px !important!important!important!important'};
  })
);
// there is no way!
{ block: 'a', tag: 'non-qwe', attrs: { style: 'font-size: 42em' } }

etc.

blond commented 8 years ago

@zxqfox +1 for force()

qfox commented 8 years ago

@blond image

miripiruni commented 8 years ago

Closed in favor of https://github.com/bem/bem-xjst/issues/340: Apply templates for mixes.

miripiruni commented 7 years ago

Closed in favor of #241