Git Product home page Git Product logo

Comments (7)

mishanga avatar mishanga commented on June 26, 2024 1

Сатанинский шаблон.
Лучше как-то так:

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.

qfox avatar qfox commented on June 26, 2024

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.

miripiruni avatar miripiruni commented on June 26, 2024

Простите, что врываюсь в тред. Но шаблон на bem-xjst тоже какой-то сатанинский. @a-x- какую задачу ты хочешь решить?

Кроме того, у меня сложилось впечатление, что:

  1. Ты перепутал местам что к чему миксуешь. Проще примиксовать tabbar к tab-menu в этой ситуации, если я правильно понимаю желаемый результат.
  2. Исходный шаблон просто не работает. Я ничего не понял про за два this.extend(…) в твоём примера. this.extend(this.mix, …) писать нельзя.
  3. this.mix не существует, есть только this.ctx.mix,
  4. 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.

miripiruni avatar miripiruni commented on June 26, 2024

@a-x- прочитай, пожалуйста, еще раз про то, что доступно в теле шаблона.

  1. Нормализованные сведения про узел на который наматчился шаблон
    this.block, this.elem, this.mods, this.elemMods
  2. this.ctx — ссылка на текущий узел из BEMJSON со всеми вытекающими.
  3. всякие хелперы в this типа extend и проч.

from bh.

a-x- avatar a-x- commented on June 26, 2024

@miripiruni
а почему mix не нормализуется?

Кажется, логично ожидать доступным this.mix который будет всегда массивом.
В вырожденных случаях пустым или из одного bem-name объекта (если в bemjson была строка 'block', то объект приведённый из неё {block: 'block'})

from bh.

a-x- avatar a-x- commented on June 26, 2024

а если я примиксую tabs-menu то его шаблоны же не применятся, а они нужны, т.к. я делаю наследование

https://goo.gl/azGop3

from bh.

a-x- avatar a-x- commented on June 26, 2024

хочу block('tabbar').inherit('tabs-menu')....foobar()
чтобы вся магия происходила внутри

from bh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.