Comments (7)
Сатанинский шаблон.
Лучше как-то так:
bh.match('tabbar', function(ctx) {
ctx.js(true);
ctx.mod('show-extra', 'no');
return {
block: 'tabs-menu',
mix: [].concat(ctx.json(), ctx.mix())
};
});
from bh.
Guess, like this:
bh.match('tabbar', function(ctx, json) {
return {
block: 'tabs-menu',
mix: bh.extend(ctx.mix(), [{
block: 'tabbar',
mods: bh.extend(ctx.mods(), {'show-extra': 'no'}),
js: true
}])
};
});
from bh.
Простите, что врываюсь в тред. Но шаблон на bem-xjst тоже какой-то сатанинский. @a-x- какую задачу ты хочешь решить?
Кроме того, у меня сложилось впечатление, что:
- Ты перепутал местам что к чему миксуешь. Проще примиксовать tabbar к tab-menu в этой ситуации, если я правильно понимаю желаемый результат.
- Исходный шаблон просто не работает. Я ничего не понял про за два
this.extend(…)
в твоём примера.this.extend(this.mix, …)
писать нельзя. this.mix
не существует, есть толькоthis.ctx.mix
,this.ctx.mix
может быть чем угодно, но чаще всего объектом или массивом. Значит this.extend не применим. Ты наверное имел ввиду приведение к массиву и пуш в него, да?
Итого должно получится как-то так:
{
block: 'tabbar',
mods: { m: 'v' },
mix: { block: 'mixed' }
}
block('tabbar')(
def()(function() {
this.mods['show-extra'] = 'no';
return applyNext();
}),
js()(true),
mix()('tabs-menu')
)
<div class="tabbar tabbar_m_v tabbar_show-extra_no tabs-menu mixed i-bem" data-bem='{"tabbar":{}}'></div>
Можно покрутить повертеть в Online demo: https://goo.gl/SmDSTa
from bh.
@a-x- прочитай, пожалуйста, еще раз про то, что доступно в теле шаблона.
- Нормализованные сведения про узел на который наматчился шаблон
this.block, this.elem, this.mods, this.elemMods - this.ctx — ссылка на текущий узел из BEMJSON со всеми вытекающими.
- всякие хелперы в this типа extend и проч.
from bh.
@miripiruni
а почему mix не нормализуется?
Кажется, логично ожидать доступным this.mix который будет всегда массивом.
В вырожденных случаях пустым или из одного bem-name объекта (если в bemjson была строка 'block'
, то объект приведённый из неё {block: 'block'}
)
from bh.
а если я примиксую tabs-menu то его шаблоны же не применятся, а они нужны, т.к. я делаю наследование
from bh.
хочу block('tabbar').inherit('tabs-menu')....foobar()
чтобы вся магия происходила внутри
from bh.
Related Issues (20)
- Readme: describe `bh.toHtml()`
- block vs. block_mod apply bug (order matters!) HOT 6
- Need documentation on new global matcher feature
- jsElem
- jsAttr Defaults: `data-bem` name + `json` scheme HOT 7
- bh.require
- Documentation on escaping utils
- Proposal: ctx.if() HOT 5
- Add more examples for boolean attributes to README
- add tProxy shortcut
- Bug with ctx.js() HOT 6
- BH doesn't extend client 'js' param when it equal true HOT 3
- How to off escaping for .content() HOT 4
- Демо не работает в Firefox
- tParam rewrites value from previous level HOT 2
- Option to drop trailing slashes for short tags
- Remove eval from runtime HOT 2
- What about escaping specific BEMJSON field, e.g. 'contentSafe'? HOT 14
- Матчинг на элемент по модификатору блока HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bh.