bem / bem-xjst

bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server
https://bem.github.io/bem-xjst
Other
115 stars 47 forks source link

Docs: BEMTREE landing #332

Closed miripiruni closed 7 years ago

miripiruni commented 8 years ago

Цитирую обращение пользователя @tadatuta

я только что в очередной раз поймал себя на том, что с новой докой на bem-xjst некуда давать ссылку на историю про BEMTREE.

раньше была отдельная дока про BEMTREE и дока про двухуровневую шаблонизацию в целом. они были протухшие и сложные, но хоть были.

Слав, ты можешь в своей фирменной манере человекопонятного повествования написать такую? А то я пока кидаю людям вот это: https://github.com/tadatuta/bem-bemtree-static-project-stub/blob/master/README.ru.md

miripiruni commented 8 years ago

@tadatuta @vithar is it right that I can not use this modes in BEMTREE?

attrs()

Template:block('b').attrs()({ id: 'test' }). Input BEMJSON: { block: 'b' }.

Expected output BEMJSON: { block: 'b', attrs: { id: 'test' } }. Actual output BEMJSON: { block: 'b' }.

mix()

Template:block('b').mix()('mixed'). Input BEMJSON: { block: 'b' }.

Expected output BEMJSON: { block: 'b', mix: { block: 'mixed' } }. Actual output BEMJSON: { block: 'b' }.

js()

Template:block('b').js()(true). Input BEMJSON: { block: 'b' }.

Expected output BEMJSON: { block: 'b', js: true }. Actual output BEMJSON: { block: 'b' }.

bem()

Template:block('b').bem()(true). Input BEMJSON: { block: 'b' }.

Expected output BEMJSON: { block: 'b', bem: true }. Actual output BEMJSON: { block: 'b' }.

cls()

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' }.

miripiruni commented 7 years ago

@tadatuta @vithar ping

miripiruni commented 7 years ago

Related comment: https://github.com/bem/bem-xjst/issues/181#issuecomment-194799564

vithar commented 7 years ago

I think we can add these mods to bemtree.

miripiruni commented 7 years ago

Good

tadatuta commented 7 years ago

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:

  1. It will make BEMTREE slower
  2. It will be even harder for users to decide which template to choose
miripiruni commented 7 years ago

@tadatuta but how I can write templates where I need to add mix or attrs to BEMJSON?

tadatuta commented 7 years ago

обычно у тебя есть корневой блок — точка входа, который кладет в себя новые блоки, а те, в свою очередь, своих чайлдов и так далее. и вот каждый раз, когда ты создаешь чайлдов, можно указывать не только их имя, модификаторы и нужные им данные, но и миксы с атрибутами. вообще, в большинстве случаев сам блок не должен отвечать за миксы с другими сущностями. это задача родителя, который знает, что вот этот импут — не только блок input, но еще и элемент формы. если только эти миксы не про оформление (типа смиксовать с clearfix), но такому место в BEMHTML, как, собственно, и атрибутам. да, есть редкие кейсы, когда это оправдано, но в этом случае пользователь сможет сделать this.extendCtx({ mix: 'b2' }).

miripiruni commented 7 years ago

@tadatuta this.extendCtx() сейчас не существует…

miripiruni commented 7 years ago

@tadatuta хорошо, давайте на встрече голосом этот решим по этой задаче.

miripiruni commented 7 years ago

Closed in favor of https://github.com/bem/bem-xjst/issues/362