V
V
Vyacheslav Lebedev2015-01-12 09:19:16
BEM
Vyacheslav Lebedev, 2015-01-12 09:19:16

How to create in bem: block block?

I write in the console:
bem create -l desktop.blocks/ -b block1 -T css
Next, I want to create 1 more block in this block:

bem create -l desktop.blocks/block1 -b block2 -T css

To which bem replies:
warn: Level at desktop.blocks/test1 does not contain .bem subdirectory
So how do I create a block in a block with the correct level and .bem directory?
Here is an example of what it would look like in json:
block: 'block1',
content: {
    block: 'block2',
    content: [
        { ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
i, 2015-01-12
@slavikse

To create block files in desktop.blocks/block1 with the command:
You need to create a level description file desktop.blocks/block1/.bem/level.js with the content:
As a result, for bem-tools, the block1 folder will not just be a block folder, but also an override level like desktop.blocks . If this may seem convenient, see the topic Grouping Blocks Inside an Override Level .
For completeness of the answer, it is important to note that in order to use the above bemjson , it is enough to create a block block2 block with the command:
Blocks are independent components that do not need to know where they can be nested (of course, there may be exceptions). They are created at the redefinition level without a hierarchy, and nesting is described in bemjson .

A
Alexey Sosnovsky, 2015-05-09
@sosnovskyas

The whole idea of ​​BEM, in my personal understanding, lies precisely in the concept of independent blocks, and therefore what you wanted to do seems to be wrong. It would be better to do so
After that, it will be possible to add the necessary technologies with the -T key, and as I remember, it is used for those cases where the block already exists and it is required to redefine or redefine the block at some level of technology. After that, you can use it repeatedly in any block at any nesting level, regardless of the rest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question