bemmet
Simple Emmet-like tool to expand abbreviations into BEMJSON. Check out online demo.
Also available as Sublime Text and Atom plugins.
Usage
var bemmet = ;var bemjson = ; // objectvar bemjsonString = bemmet; console;// {// block: 'b1',// content: [// {// elem: 'e1',// content: [// {// block: 'b3',// mods: { theme: 'islands' },// content: {}// },// {// block: 'b1',// mods: { state: 'active' },// content: 'hello'// }// ]// },// {// elem: 'e1',// content: [// {// block: 'b3',// mods: { theme: 'islands' },// content: {}// },// {// block: 'b1',// mods: { state: 'active' },// content: 'hello'// }// ]// }// ]// }
Custom naming scheme
var bemmet = ;var abbreviation = 'b1>__e1*2>b3--islands+--active';var bemjson = bemmet; console;// {// block: 'b1',// content: [// {// elem: 'e1',// content: [// {// block: 'b3',// mods: { islands: true },// content: {}// },// {// block: 'b1',// mods: { active: true },// content: {}// }// ]// },// {// elem: 'e1',// content: [// {// block: 'b3',// mods: { islands: true },// content: {}// },// {// block: 'b1',// mods: { active: true },// content: {}// }// ]// }// ]// }
API
; // objectbemmet; // string
parentBlock
is used to explicitly define context for shortcuts like __elem
when there's no parent block in abbreviation itself.
options.naming
is used to configure BEM naming scheme. For details please refer to bem-naming.
For stringify()
method it's possible to configure indentation and quotes via options.indent
(string) and options.singleQuotes
(boolean) params.