3838
3939* [ parse] ( #parsestr-ctx )
4040* [ stringify] ( #stringify )
41+ * [ expand] ( #parsestr-ctx )
4142
4243### parse(str, ctx)
4344
4445Parameter | Type | Description
4546----------|----------|--------------------------------------------------------
4647` str ` | ` string ` | BEM import notation check [ notation section] ( #notation )
47- ` ctx ` | ` object ` | BEM entity name representation.
48+ ` [ ctx] ` | ` object ` | BEM entity name representation
4849
4950Parses the string into BEM entities.
5051
@@ -58,19 +59,16 @@ entity.elem // → 'text'
5859
5960#### ctx
6061
61- Context allows to extract portion of entities .
62+ Context allows to use short form of notation .
6263
6364``` js
6465var enties = parse (' m:theme=normal' , { block: ' button' });
6566
66- // → [ { block: 'button', mod: { name: 'theme' } },
67+ // → [ { block: 'button' },
68+ // { block: 'button', mod: { name: 'theme' } },
6769// { block: 'button', mod: { name: 'theme', val: 'normal' } } ]
6870```
6971
70- Note that, using context exludes ` { block: 'button'} ` from result.
71-
72- So ` parse('m:theme=normal', { block: 'button' }) ` is not same as ` parse('b:button m:theme=normal') `
73-
7472### stringify
7573
7674Parameter | Type | Description
@@ -80,6 +78,23 @@ Parameter | Type | Description
8078Forms a string from [ BEM entities] . Be aware to merge only one type of entities.
8179The array should contains one block or one elem and optionally it's modifiers.
8280
81+ ### expand(str, ctx)
82+
83+ Parameter | Type | Description
84+ ----------|----------|--------------------------------------------------------
85+ ` str ` | ` string ` | BEM import notation check [ notation section] ( #notation )
86+ ` ctx ` | ` object ` | BEM entity name representation
87+
88+ Expand notation string to full form by context BEM entity.
89+
90+ Example:
91+
92+ ``` js
93+ var notation = parse (' e:text' , { block: ' button' });
94+
95+ // → 'b:button e:text'
96+ ```
97+
8398Notation
8499--------
85100
0 commit comments