Skip to content

smdenis/bemjson-to-decl

 
 

Repository files navigation

bemjson-to-decl

Easy to use BEMJSON to set of BEM-entities (aka BEMDECL) converter written in JS

NPM Status Travis Status Coverage Status Dependency Status

Prerequisites

Installing

Run in your project:

npm install --save bemjson-to-decl

Usage

const bemjsonToDecl = require('bemjson-to-decl');

bemjsonToDecl.convert([
    {elem: 'control', elemMods: {theme: 'normal'}},
    {elem: 'control', elemMods: {theme: 'ghost'}}
], {block: 'button'});
// [ { block: 'button' },
//   { block: 'button', elem: 'control' },
//   { block: 'button', elem: 'control', modName: 'theme', modVal: true },
//   { block: 'button', elem: 'control', modName: 'theme', modVal: 'normal' },
//   { block: 'button', elem: 'control', modName: 'theme', modVal: 'ghost' } ]

API

convert(bemjson: BEMJSON, scope: ?BemEntityName): BemCell[]

Fetchs BEM-entities from BEMJSON object.

const bemjsonToDecl = require('bemjson-to-decl');

bemjsonToDecl.convert({block: 'button', mods: {theme: 'normal'}});
// [ { block: 'button' },
//   { block: 'button', modName: 'theme', modVal: true },
//   { block: 'button', modName: 'theme', modVal: 'normal' } ]

stringify(bemjson: BEMJSON, scope: ?BemEntityName, opts: ?{indent: string}): string

Fetchs BEM-entities and stringifies 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]"

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

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

License

Code and documentation are licensed under the Mozilla Public License 2.0 - see the LICENSE.md file for details.

About

BEMJSON to BEMDECL converter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%