bh
bh copied to clipboard
Support plain block mixes
{ block: 'a', mix: 'b' }
=> <div class="a b"></div>
Also:
ctx.mix('a__b')
=> ctx.mix()
=> '{ block: 'a', elem: 'b' }
{ mix: 'a__b_c' }
https://github.com/bem/bem-naming
I think we won't be able to support also
part in BEMHTML.
since naming separators is part of options in render function we just can't enforce any particular separator in { mix: 'a__b_c' }
inside of BH (ctx.mix('a__b')
) it's acceptable because of using particular separator in matches
What if we will expose parsing/stringifying function and let users to redefine it?
Like bh.setOption('naming', { parse: function (str): Object, stringify: function (obj): string });
to fill all internal needs. And then it will be possible to use custom syntax in both places: matchers and mixes.
upd: btw, https://github.com/bem/bh/blob/master/lib/bh.js#L763-L784 — this is the current parser. https://github.com/bem/bem-naming/blob/master/lib/bem-naming.js#L129 — parser in bem-naming
Looks like this:
bh.setOptions('naming', require('bem-naming')({ 'any-custom': 'naming-params' }));
will work in that way ;-)
such approach doesn't support mixing different styles of separators in one runtime — anyway, I think customisation of BH match syntax is different issue