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

.bydefault()/.force() helper suggestions #175

Closed qfox closed 8 years ago

qfox commented 8 years ago

We have different merging with bemjson behaviour for content, tag, cls and attrs modes.

content mode executes in anyway. tag mode won't be executed if bemjson had tag property. attrs & cls from template will be merged with attrs property in result.

All of this forces users to use .def mode while using it much can significantly decrease performance.

I guess we should make as many helpers as we can to reduce .def usage at all.

The bright example is .bydefault helper that can hold the value for this mode by default (if property doesn't exist in users data).

Template can look like:

block('input').bydefault()(
  tag()('input'),
  attrs()({placeholder: 'Enter a value'})
  // etc.
);

And then we can redefine this easily with our current templates as well.

Also there are example with inconsistency between tag, content and attrs: sandbox example

/cc @veged @indutny

veged commented 8 years ago

I think we need just clarify difference for redefining between all modes and keep BEMXJST terms domain as thin as possible.

qfox commented 8 years ago

@veged Did you even read description? ;-)

veged commented 8 years ago

@zxqfox formally yes — I try my best ;-)

read twice and still remain in conviction with my comment

so let's discuss it offline on nearest meeting