bemcn is an utility for creating BEM class names.
var bc = bemcn('__', '--');
bc('b')()() // b
bc('b')()('m') // b--m
bc('b')()('m', true) // b b--m
bc('b')('e')() // b__e
bc('b')('e')('m') // b__e--m
bc('b')('e')('m', true) // b__e b__e--m
var bc = bemcn('__', '--', true);
bc('b')()() // b
bc('b')()('m', false) // b--m
bc('b')()('m') // b b--m
bc('b')('e')() // b__e
bc('b')('e')('m', false) // b__e--m
bc('b')('e')('m') // b__e b__e--m
$ npm install --save bemcn
<script src="path/to/bemcn.js"></script>
<script>
var bcn = bemcn('__', '--');
bcn('block')('element')('modifier');
</script>
requirejs(['path/to/bemcn'], function(bemcn) {
var bcn = bemcn('__', '--');
bcn('block')('element')('modifier');
});
var bemcn = require('bemcn');
var bcn = bemcn('__', '--');
bcn('block')('element')('modifier');
- bemcn(ep, mp, [wbd]) ⇒
b
BEM class names
- b(v) ⇒
e
block creator
- e([v]) ⇒
m
element creator
- m([v], [wb]) ⇒
string
modifier and result creator
bemcn(ep, mp, [wbd]) ⇒ b
BEM class names
Kind: global function
Returns: b
- - block creator
Param | Type | Description |
---|---|---|
ep | string |
element prefix |
mp | string |
modifier prefix |
[wbd] | boolean |
with base class name (default value) |
b(v) ⇒ e
block creator
Kind: global function
Returns: e
- - element creator
Param | Type | Description |
---|---|---|
v | string |
block name |
e([v]) ⇒ m
element creator
Kind: global function
Returns: m
- - modifier and result creator
Param | Type | Description |
---|---|---|
[v] | string |
element name |
modifier and result creator
Kind: global function
Returns: string
- - result
Param | Type | Description |
---|---|---|
[v] | string |
modifier name |
[wb] | boolean |
with base class name (default wbd) |
var bcn = bemcn('__', '--', true);
var form = bcn('form');
var field = form('field');
var label = form('label');
form()('inline') // form form--inline
field() // form__field
field('error') // form__field form__field--error
label() // form__label
label('hidden') // form__label form__label--hidden
- Fork the project.
- Make your feature addition or bug fix.
- Send me a pull request.
© 2017 Vasily Shilov