bem / bem-sdk

BEM SDK packages
https://en.bem.info/toolbox/sdk/
86 stars 24 forks source link

Implement BEMJSON notation #67

Closed andre487 closed 8 years ago

andre487 commented 9 years ago

Will be very helpful if there will be full BEMJSON support:

bemNaming.stringify({block: 'page', mods: {type: 'inner'}, mix: {block: 'page-404', elem: 'content', elemMods: {type: 'any'}}});
// page page_type_inner page-404__content_type_any 
tadatuta commented 9 years ago

it should be implemented as separate package which uses bem-naming as bem-naming itself is all about one entity

andre487 commented 9 years ago

Can it be separate method in bem-naming? E. g. bemNaming.fromBemJson(bemJson)

blond commented 8 years ago

The bem-naming works with one entity (stringify object or parse string).

BEMJSON contains several entities, so it looks more like a declaration.

If you want convert BEMJSON to BEMDECL need use bemjson-to-decl package:

import bemNaming from 'bem-naming';
import toDecl from 'bemjson-to-decl';

const bemjson = {
    block: 'page', 
    mods: { type: 'inner' }, 
    mix: {
        block: 'page-404',
        elem: 'content', 
        elemMods: { type: 'any' }
    }
};

const bemdecl = toDecl(bemjson);

bemdecl.map(bemNaming.stringify); // page page_type_inner page-404__content_type_any 

If you still have questions, reopen this issue or create a new issue.

andre487 commented 8 years ago

Thanks! It's the solution