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

Modifier templates does not apply #482

Open qfox opened 7 years ago

qfox commented 7 years ago

Input code or something about issue background

https://goo.gl/Xm3cWQ

block('a').def()('NO');
block('a').mods()({m: true});
block('a').mod('m').def()('YES');

Feels like it's too late but looks like a bug or useless sugar and we should fix that (modifier templates should apply).

Expected Behavior

'YES'

Actual Behavior

'NO'

Possible Solution

Apply mods/addMods BEFORE def mode?

Your Environment

latest bem-xjst

cc @Yeti-or @awinogradov

miripiruni commented 7 years ago

Today’s version bem-xjst have hierarchy of modes. def() mode is "first class" mode. The rest modes are "second class" modes. It means if a def() template has been defined other templates was not applied. It was done this way because users need full control. How is it suggested to control the templates in your case?

In your example https://goo.gl/Xm3cWQ you would get 'YES' if BEMJSON would be { block: 'a', mods: { m: true } }.

qfox commented 7 years ago

Yep, but we think this is wrong.

sbmaxx commented 7 years ago

Any progress here?

miripiruni commented 7 years ago

we think this is wrong

who are "we"?

awinogradov commented 7 years ago

Look at the likes ;)