Closed isqua closed 9 years ago
I'll do something about it on this week.
I’ve written small hack in my project: my script recursively traverses the tree and replace mods
with elemMods
on each elem node and blockMods
with mods
on each node. But there is a problem in some cases.
When mods
property is defined on elem node, BEMHTML use these mods to build class name of the elem.
Source JSON:
{
"block": "myblock",
"mods": {
"theme": "dark"
},
"content": [
{ "elem": "myelem" }
]
}
JSON after bh.processBemJson
:
{
"block": "myblock",
"mods": {
"theme": "dark"
},
"content": [
{
"elem": "myelem",
"block": "myblock",
"blockMods": {
"theme": "dark"
}
}
],
"blockMods": {
"theme": "dark"
}
}
JSON after the hack:
{
"block": "myblock",
"mods": {
"dark": "dark"
},
"content": [
{
"elem": "myelem",
"block": "myblock",
"mods": {
"theme": "dark"
}
}
]
}
So the result class of the elem is myblock__myelem myblock__myelem_theme_dark
, but I expected only myblock__myelem
. If I remove mods
property from elem, BEMHTML templates for
block myblock, mod theme dark, elem myelem
don’t work. But if I remove mods
and block
properties, BEMHTML consider this condition. But it will cause problems with constructions like this:
{
"block": "block1",
"content": {
"block": "block2",
"content": {
"block": "block1",
"elem": "myelem"
}
}
}
Assuming the facts that:
block
and blockMods
(source code around these is not pretty clear for me, my bad), andI would suggest just adding an additional flag (__addedBlock / __deleteBlock
, don't really care) to the elem
nodes which are populated with the block
property. So, using the hack described above, we would tell, if the elem
node had the block
property originally, or the prop was added during processBemJson
transformation.
I need to get some BEMJSON from BH layer and then compile it to HTML with BEMHTML. But BH process this structure:
into this:
And the fragment
is parsed wrong with BEMHTML. If it was
mods
instead ofblockMods
, BEMHTML would work as I expected.May be it is possible to add an option for this parameter? How could I solve the problem now?