Skip to content

Commit e00979a

Browse files
author
Ivan Demidov
committed
Added extends description
1 parent caa1c3d commit e00979a

File tree

1 file changed

+65
-46
lines changed

1 file changed

+65
-46
lines changed

README.md

+65-46
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
```
1414
## Usage
1515

16-
Plugins will be loaded directly from your projects ***package.json*** file.
17-
Install them as usual with ``` npm i -S ``` or ``` npm i -D ```.
16+
Plugins will be loaded directly from your projects ***package.json*** file or local installed plugins.
17+
Install them as usual with ``` npm i -S ``` or ``` npm i -D ``` or ```npm i```.
1818

1919
[PostHTML Plugins](https://maltsev.github.io/posthtml-plugins/)
2020

@@ -24,6 +24,7 @@ After installing your plugins there a three ways to declare your plugin options.
2424
- Set options in your ***package.json***.
2525
- Create a separated ***[name].[ext]*** file, where ***[name]*** is any name you like and ***[ext]*** should be either ``` .js ``` or ``` .json ```.
2626
For an example of well formed options file see below.
27+
- For plugins not having rules installed locally will be used default settings.
2728

2829
## Options
2930

@@ -32,26 +33,26 @@ For an example of well formed options file see below.
3233
```json
3334
{
3435
"dependencies": {
35-
"posthtml-bem": "^0.2.2",
36-
"posthtml-each": "^1.0.1",
37-
"posthtml-include": "^1.0.2"
36+
"posthtml-bem": "^0.2.2",
37+
"posthtml-each": "^1.0.1",
38+
"posthtml-include": "^1.0.2"
3839
},
3940
"devDependencies": {
40-
"posthtml-style-to-file": "^0.1.1"
41+
"posthtml-style-to-file": "^0.1.1"
4142
},
4243
"posthtml": {
43-
"bem": {
44-
"elemPrefix": "__",
45-
"modPrefix": "-",
46-
"modDlmtr": "--"
47-
},
48-
"include": {
49-
"root": "./",
50-
"encoding": "utf-8"
51-
},
52-
"styleToFile": {
53-
"path": "./dist/style.css"
54-
}
44+
"bem": {
45+
"elemPrefix": "__",
46+
"modPrefix": "-",
47+
"modDlmtr": "--"
48+
},
49+
"include": {
50+
"root": "./",
51+
"encoding": "utf-8"
52+
},
53+
"styleToFile": {
54+
"path": "./dist/style.css"
55+
}
5556
}
5657
}
5758
```
@@ -61,36 +62,36 @@ For an example of well formed options file see below.
6162
#### JS
6263
```js
6364
module.exports = {
64-
bem: {
65-
elemPrefix: '__',
66-
modPrefix: '-',
67-
modDlmtr: '--'
68-
},
69-
include: {
70-
root: './',
71-
encoding: 'utf-8'
72-
},
73-
styleToFile: {
74-
path: './dist/style.css'
75-
}
65+
bem: {
66+
elemPrefix: '__',
67+
modPrefix: '-',
68+
modDlmtr: '--'
69+
},
70+
include: {
71+
root: './',
72+
encoding: 'utf-8'
73+
},
74+
styleToFile: {
75+
path: './dist/style.css'
76+
}
7677
}
7778
```
7879
#### JSON
7980

8081
```json
8182
{
82-
"bem": {
83-
"elemPrefix": "__",
84-
"modPrefix": "-",
85-
"modDlmtr": "--"
86-
},
87-
"include": {
88-
"root": "./",
89-
"encoding": "utf-8"
90-
},
91-
"styleToFile": {
92-
"path": "./dist/style.css"
93-
}
83+
"bem": {
84+
"elemPrefix": "__",
85+
"modPrefix": "-",
86+
"modDlmtr": "--"
87+
},
88+
"include": {
89+
"root": "./",
90+
"encoding": "utf-8"
91+
},
92+
"styleToFile": {
93+
"path": "./dist/style.css"
94+
}
9495
}
9596
```
9697

@@ -111,8 +112,8 @@ const plugins = require('posthtml-load-plugins')()
111112
let html = fs.readFileSync('./index.html', 'utf8')
112113

113114
posthtml(plugins)
114-
.process(html)
115-
.then(result => console.log(result.html))
115+
.process(html)
116+
.then(result => console.log(result.html))
116117
```
117118

118119
#### Options file (e.g posthtml.json)
@@ -128,9 +129,27 @@ const plugins = require('posthtml-load-plugins')('posthtml.(js|json)')
128129
let html = fs.readFileSync('./index.html', 'utf8')
129130

130131
posthtml(plugins)
131-
.process(html)
132-
.then(result => console.log(result.html))
132+
.process(html)
133+
.then(result => console.log(result.html))
133134
```
135+
136+
#### Extends options
137+
138+
```js
139+
'use strict'
140+
141+
const fs = require('fs')
142+
143+
const posthtml = require('posthtml')
144+
const plugins = require('posthtml-load-plugins')('posthtml.(js|json)', {"posthtml-bem": {elemPrefix: '__'}})
145+
146+
let html = fs.readFileSync('./index.html', 'utf8')
147+
148+
posthtml(plugins)
149+
.process(html)
150+
.then(result => console.log(result.html))
151+
```
152+
134153
## Contributors
135154

136155
[![GitScrum](https://avatars.githubusercontent.com/u/2789192?s=130)](https://github.com/GitScrum) |

0 commit comments

Comments
 (0)