Closed miripiruni closed 7 years ago
@tadatuta @vithar is it right that I can not use this modes in BEMTREE?
Template:block('b').attrs()({ id: 'test' })
.
Input BEMJSON: { block: 'b' }
.
Expected output BEMJSON: { block: 'b', attrs: { id: 'test' } }
.
Actual output BEMJSON: { block: 'b' }
.
Template:block('b').mix()('mixed')
.
Input BEMJSON: { block: 'b' }
.
Expected output BEMJSON: { block: 'b', mix: { block: 'mixed' } }
.
Actual output BEMJSON: { block: 'b' }
.
Template:block('b').js()(true)
.
Input BEMJSON: { block: 'b' }
.
Expected output BEMJSON: { block: 'b', js: true }
.
Actual output BEMJSON: { block: 'b' }
.
Template:block('b').bem()(true)
.
Input BEMJSON: { block: 'b' }
.
Expected output BEMJSON: { block: 'b', bem: true }
.
Actual output BEMJSON: { block: 'b' }
.
Template:block('b').cls()('my-custom-html-class')
.
Input BEMJSON: { block: 'b' }
.
Expected output BEMJSON: { block: 'b', cls: 'my-custom-html-class' }
.
Actual output BEMJSON: { block: 'b' }
.
@tadatuta @vithar ping
Related comment: https://github.com/bem/bem-xjst/issues/181#issuecomment-194799564
I think we can add these mods to bemtree.
Good
Oh, I lost this issue for some reason.
It was done on purpose: BEMTREE is just about data and these mods are about HTML output. All these fiels can be easily set in parent. So I vote against it:
@tadatuta but how I can write templates where I need to add mix or attrs to BEMJSON?
обычно у тебя есть корневой блок — точка входа, который кладет в себя новые блоки, а те, в свою очередь, своих чайлдов и так далее.
и вот каждый раз, когда ты создаешь чайлдов, можно указывать не только их имя, модификаторы и нужные им данные, но и миксы с атрибутами.
вообще, в большинстве случаев сам блок не должен отвечать за миксы с другими сущностями. это задача родителя, который знает, что вот этот импут — не только блок input
, но еще и элемент формы. если только эти миксы не про оформление (типа смиксовать с clearfix
), но такому место в BEMHTML, как, собственно, и атрибутам.
да, есть редкие кейсы, когда это оправдано, но в этом случае пользователь сможет сделать this.extendCtx({ mix: 'b2' })
.
@tadatuta this.extendCtx()
сейчас не существует…
@tadatuta хорошо, давайте на встрече голосом этот решим по этой задаче.
Closed in favor of https://github.com/bem/bem-xjst/issues/362
Цитирую обращение пользователя @tadatuta