-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.hbs
96 lines (72 loc) · 2.22 KB
/
README.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
[![view on npm](http://img.shields.io/npm/v/bemcn.svg)](https://www.npmjs.org/package/bemcn)
[![npm module downloads](http://img.shields.io/npm/dt/bemcn.svg)](https://www.npmjs.org/package/bemcn)
[![Build Status](https://travis-ci.org/uxter/bemcn.svg?branch=master)](https://travis-ci.org/uxter/bemcn)
[![Coverage Status](https://codecov.io/gh/uxter/bemcn/branch/master/graph/badge.svg)](https://codecov.io/gh/uxter/bemcn)
[![Dependency Status](https://david-dm.org/uxter/bemcn.svg)](https://david-dm.org/uxter/bemcn)
[![Join the chat at https://gitter.im/bemcn](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bemcn?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# bemcn
bemcn is an utility for creating BEM class names.
## Explanation
```js
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
```
```js
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
```
## Install
```
$ npm install --save bemcn
```
## Usage
#### Browser
```html
<script src="path/to/bemcn.js"></script>
<script>
var bcn = bemcn('__', '--');
bcn('block')('element')('modifier');
</script>
```
#### AMD
```js
requirejs(['path/to/bemcn'], function(bemcn) {
var bcn = bemcn('__', '--');
bcn('block')('element')('modifier');
});
```
#### Node.js
```js
var bemcn = require('bemcn');
var bcn = bemcn('__', '--');
bcn('block')('element')('modifier');
```
{{>main}}
## Example
```js
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
```
## Note on Patches/Pull Requests
1. Fork the project.
2. Make your feature addition or bug fix.
3. Send me a pull request.
* * *
© 2017 Vasily Shilov