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

attrs mod doesn't get block context #421

Closed Yeti-or closed 6 years ago

Yeti-or commented 7 years ago

https://goo.gl/jHqyY4

In bemjson attrs values we could use other entities:

{ 
    block: 'button', 
    attrs: {
        // this works
        name: { block: 'button', elem: 'key'},
        // this doesn't
        id: { elem: 'key'}
    }
}

but elems don't behave as in other modes (content, mix)

miripiruni commented 6 years ago

Because in case id: { elem: 'key' } BEMHTML takes {elem: 'key' } as an input bemjson and starts templating. 1) https://github.com/bem/bem-xjst/blob/master/lib/bemhtml/index.js#L175 2) https://github.com/bem/bem-xjst/blob/master/lib/bemxjst/index.js#L314

If I’ll change this behaviour as you wish (extend {elem: 'key'} with block and elem from context) it may harm backward capability.

If you don’t mind I close this issue.