Bemmet
Simple Emmet-like tool to expand shorcuts into BEMJSON
Install / Use
/learn @tadatuta/BemmetREADME
bemmet
Simple Emmet-like tool to expand abbreviations into BEMJSON. Check out online demo.
Also available as Sublime Text, VS Code, Atom and IntelliJ * plugins.
Usage
var bemmet = require('bemmet');
var bemjson = bemmet('b1>__e1*2>b3_theme_islands+_state_active{hello}'); // object
var bemjsonString = bemmet.stringify('b1>__e1*2>b3_theme_islands+_state_active{hello}');
console.log(bemjsonString);
// {
// 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 = require('bemmet');
var abbreviation = 'b1>__e1*2>b3--islands+--active';
var bemjson = bemmet.stringify(abbreviation, {
naming: {
elem: '__',
mod: '--'
}
});
console.log(bemjson);
// {
// 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
bemmet(abbreviation, [parentBlock], [options]); // object
bemmet.stringify(abbreviation, [parentBlock], [options]); // 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.
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
