Easy to use BEMJSON to set of BEM-entities (aka BEMDECL) converter written in JS
- Node.js 4.x+
Run in your project:
npm install --save bemjson-to-decl
const bemjsonToDecl = require('bemjson-to-decl');
bemjsonToDecl.convert([
{elem: 'control', elemMods: {theme: 'normal'}},
{elem: 'control', elemMods: {theme: 'ghost'}}
], {block: 'button'});
// →
// [ BemEntityName { block: 'button', elem: 'control' },
// BemEntityName { block: 'button', elem: 'control', mod: { name: 'theme', val: true } },
// BemEntityName { block: 'button', elem: 'control', mod: { name: 'theme', val: 'normal' } },
// BemEntityName { block: 'button', elem: 'control', mod: { name: 'theme', val: 'ghost' } }
// ]
Extract BEM-entities from BEMJSON object.
const bemjsonToDecl = require('bemjson-to-decl');
bemjsonToDecl.convert({block: 'button', mods: {theme: 'normal'}});
// →
// [ BemEntityName { block: 'button' },
// BemEntityName { block: 'button', mod: { name: 'theme', val: true } },
// BemEntityName { block: 'button', mod: { name: 'theme', val: 'normal' } }
// ]
Extract BEM-entities and stringify result to the string.
const bemjsonToDecl = require('bemjson-to-decl');
bemjsonToDecl.stringify({block: 'button'}, null, {indent: '\t'});
// →
// "[\n\t{\n\t\tblock: 'button'\n\t}\n]"
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Vladimir Grinenko - Initial work - tadatuta
See also the full list of contributors who participated in this project.
You may also get it with git log --pretty=format:"%an <%ae>" | sort -u
.
Code and documentation are licensed under the Mozilla Public License 2.0 - see the LICENSE.md file for details.