Created
March 3, 2013 17:56
-
-
Save RubaXa/5077273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fest:template> | |
&bem b-datalist { | |
ctx.head ? &__head ctx.head | |
for item in ctx.items { | |
&__item item | |
} | |
ctx.foot ? &__foot ctx.foot | |
} | |
&bem b-datalist__item { | |
cols = $block.getCols(); | |
mods: { | |
"first": $first && !$parent.head | |
"last": $last | |
"selected": $parent.selected[ctx.id] | |
} | |
cols.cbx ? &__cbx { | |
&cbx { checked: ctx.selected } | |
} | |
cols.pic ? &__pic { | |
style: "background-image: url('{$block.getItemPic(ctx)}');" | |
} | |
} | |
</fest:template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fest:template> | |
&bem cbx { | |
mods: { | |
"checked": ctx.checked | |
"disabled": ctx.disabled | |
} | |
&__checkmark {} | |
} | |
</fest:template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fest:template> | |
<fest:set name="cbx"> | |
<div> | |
<fest:attributes> | |
<fest:if test="params.id"> | |
<fest:attribute name="data-id"> | |
<fest:value>params.id</fest:value> | |
</fest:attribute> | |
</fest:if> | |
<fest:if test="params.name"> | |
<fest:attribute name="data-name"> | |
<fest:value>params.name</fest:value> | |
</fest:attribute> | |
</fest:if> | |
<fest:if test="params.mnemo"> | |
<fest:attribute name="data-mnemo"> | |
<fest:value>params.mnemo</fest:value> | |
</fest:attribute> | |
</fest:if> | |
<fest:attribute name="class"> | |
cbx | |
<fest:if test="params.mods"> | |
<fest:value>' cbx_'+params.join(' cbx_')</fest:value> | |
</fest:if> | |
<fest:if test="params.checked"> | |
<fest:space/> | |
cbx_checked | |
</fest:if> | |
<fest:if test="params.disabled"> | |
<fest:space/> | |
cbx_disabled | |
</fest:if> | |
</fest:attribute> | |
</fest:attrbiutes> | |
<div class="cbx__checkmark"></div> | |
</div> | |
</fest:set> | |
</fest:template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Пока с
params.mods
проблем не было. В атрибутclass
нельзя давать писать что-угодно, только черезmods
иmixin
какой-нибудь.Код медленный на сетах и гетах, да. Какие предложения?
Мое видение такое. БЭМ блок должен остаться функцией - по сути обычный set. Компилятор должен инлайнить get безусловных блоков, которые используются только один раз. То есть даже целый БЭМ блок может оказаться инлайном, что гуд. Инлайн в данном случае означает: не откладывать вызов блока на конец шаблона, а вызывать по месту использования. Можно пойти еще дальше, и инлайнить без вызова - прямо код, но нужно как гарантировать целостность контекста, ведь в сетах может быть
fest:script
с локальным переменными. Такую оптимизацию можно сделать по-желанию, и придерживаться стиля именования переменных в скриптах с префиксами - имена блоков и элементов.