Skip to content

Commit 550bbbf

Browse files
committed
docs(import-notation): add expand and fix parse in readme
1 parent 8b94a32 commit 550bbbf

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

packages/import-notation/README.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ API
3838

3939
* [parse](#parsestr-ctx)
4040
* [stringify](#stringify)
41+
* [expand](#parsestr-ctx)
4142

4243
### parse(str, ctx)
4344

4445
Parameter | 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

4950
Parses 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
6465
var 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

7674
Parameter | Type | Description
@@ -80,6 +78,23 @@ Parameter | Type | Description
8078
Forms a string from [BEM entities]. Be aware to merge only one type of entities.
8179
The 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+
8398
Notation
8499
--------
85100

0 commit comments

Comments
 (0)