Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Dependencies for Block #82

Open
beinoriusju opened this issue Aug 28, 2019 · 0 comments
Open

Dynamic Dependencies for Block #82

beinoriusju opened this issue Aug 28, 2019 · 0 comments

Comments

@beinoriusju
Copy link

First of all, thanks for such an amazing methodology and tools. I'm very happy so far about the results.

Here is a little problem I'm facing.

{
    block: 'menu',
    type: 'red', // NOTICE i'm intentionally defining it as type not as mod
    items: [
        { title: 'BBC', url: 'http://bbc.co.uk'},
        { title: 'CNN', url: 'http://cnn.com'}
    ]
}

My BEMJSON layouts being more abstract makes me more productive. I would like to ignore details like mods, elems and define them "on the fly" with BEMHTML block (re?)definitions.

block('menu')(
    mods()(function() {
        let custom_mods = {}

        custom_mods[this.ctx.type ? this.ctx.type : 'black'] = true; // menu_red, menu_black, etc.
    
        return Object.assign({}, this.ctx.mods, custom_mods)
    })
)

The possibilities are endless here. Amazing. Just what I wanted...

Except! My dependencies for menu_red are not included now.

Adding red mod to menu.deps.js is not a solution, because this way red is part of the bundle although BEMJSON defines only GREEN.

Is there a workaround? Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant