1- [ ![ NPM] [ npm ]] [ npm-url ]
2- [ ![ Deps] [ deps ]] [ deps-url ]
3- [ ![ Tests] [ build ]] [ build-url ]
4- [ ![ Coverage] [ cover ]] [ cover-url ]
5- [ ![ Standard Code Style] [ style ]] [ style-url ]
6- [ ![ Chat] [ chat ]] [ chat-badge ]
7-
8- # Gulp PostHTML <img align =" right " width =" 200 " height =" 220 " title =" PostHTML " src =" http://posthtml.github.io/posthtml/logo.svg " >
9-
10- ## Install
1+ [ ![ npm] [ npm ]] [ npm-url ]
2+ [ ![ node] [ node ]] [ node-url ]
3+ [ ![ deps] [ deps ]] [ deps-url ]
4+ [ ![ tests] [ tests ]] [ tests-url ]
5+ [ ![ coverage] [ cover ]] [ cover-url ]
6+ [ ![ code style] [ style ]] [ style-url ]
7+ [ ![ chat] [ chat ]] [ chat-url ]
8+
9+ <div align =" center " >
10+ <img width =" 100 " height =" 200 " src =" https://worldvectorlogo.com/logos/gulp.svg " >
11+ <a href =" https://github.com/posthtml/posthtml " >
12+ <img width="220" height="200" title="PosHTML" src="http://posthtml.github.io/posthtml/logo.svg">
13+ </a >
14+ <h1 >Gulp PostHTML</h1 >
15+ <p >PostHTML Plugin for Gulp<p >
16+ </div >
17+
18+ <h2 align =" center " >Install</h2 >
1119
1220``` bash
1321npm i -D gulp-posthtml
1422```
1523
16- ## Usage
17-
18- ### Static
24+ <h2 align =" center " >Usage</h2 >
1925
2026``` js
2127import { task , src , dest } from ' gulp'
2228
2329import posthtml from ' gulp-posthtml'
2430
2531task (' html' , () => {
26- const plugins = [
27- require (' posthtml-include' )({ root: ' ./components' }),
28- require (' posthtml-custom-elements' )()
29- ]
30- const options = { parser: require (' sugarml' ) }
31-
32- return src (' src/*.html' )
33- .pipe (posthtml (plugins, options))
34- .pipe (gulp .dest (' dest' ))
32+ return src (' src/*.html' )
33+ .pipe (posthtml ())
34+ .pipe (dest (' dest' ))
3535})
3636```
3737
38- ### Dynamic
38+ < h2 align = " center " >Options</ h2 >
3939
40- ``` js
40+ ### Plugins
41+
42+ ** ` plugins ` ** : ** ` {Array} ` ** PostHTML Plugins
4143
44+ ### Options
45+
46+ ** ` options ` ** : ** ` {Object} ` ** PostHTML Options
47+
48+ :warning : ` posthtml.config.js ` will not be loaded, when ` plugins ` and/or ` options ` are specified.
49+
50+ ** gulpfile.js**
51+ ``` js
4252import { task , src , dest } from ' gulp'
4353
4454import tap from ' gulp-tap'
55+ import rename from ' gulp-rename'
4556import posthtml from ' gulp-posthtml'
4657
4758task (' html' , () => {
4859 let path
49-
50- const plugins = [
51- require (' posthtml-include' )({ root: ` ${ path} /components` }),
52- require (' posthtml-custom-elements' )()
53- ]
54- const options = { parser: require (' sugarml' ) }
60+ const plugins = [ require (' posthtml-include' )({ root: path }) ]
61+ const options = { parser: require (' posthtml-sugarml' )() }
5562
5663 return src (' src/*.html' )
5764 .pipe (tap ((file ) => path = file .path ))
5865 .pipe (posthtml (plugins, options))
59- .pipe (gulp .dest (' dest' ))
66+ .pipe (rename ({ ext: ' .html' }))
67+ .pipe (dest (' dest' ))
68+ })
69+ ```
70+
71+ ### Config
72+
73+ ##### Context
74+
75+ ** ` ctx ` ** : ** {Object}** PostHTML Config
76+
77+ ** posthtml.config.js**
78+ ``` js
79+ module .exports = (ctx ) => {
80+ return {
81+ parser: ctx .ext == ' .sml' ? ' posthtml-sugarml' : false ,
82+ plugins: {
83+ ' posthtml-include' : ctx .include ,
84+ ' htmlnano' : ctx .env === ' production' ? null : false
85+ }
86+ }
87+ }
88+ ```
89+
90+ ** gulpfile.js**
91+ ``` js
92+ import { task , src , dest } from ' gulp'
93+
94+ import tap from ' gulp-tap'
95+ import rename from ' gulp-rename'
96+ import posthtml from ' gulp-posthtml'
97+
98+
99+ task (' sml' , () => {
100+ const ctx = { ext: ' .sml' , include: {} }
101+
102+ return src (' src/*.sml' )
103+ .pipe (tap ((file ) => ctx .include .root = file .path ))
104+ .pipe (posthtml (ctx))
105+ .pipe (rename ({ ext: ' .html' }))
106+ .pipe (dest (' dest' ))
107+ })
108+
109+ task (' html' , () => {
110+ const ctx = { include: {} }
111+
112+ return src (' src/*.html' )
113+ .pipe (tap ((file ) => ctx .include .root = file .path ))
114+ .pipe (posthtml (ctx))
115+ .pipe (dest (' dest' ))
60116})
61117```
62118
63- ## Maintainers
119+ < h2 align = " center " >Maintainer</ h2 >
64120
65121<table >
66122 <tbody >
@@ -75,22 +131,32 @@ task('html', () => {
75131 <tbody >
76132</table >
77133
78- ## Contributing
79-
80- See [ PostHTML Guidelines] ( https://github.com/posthtml/posthtml/tree/master/docs ) and [ CONTRIBUTING] ( CONTRIBUTING.md ) .
81-
82- ## LICENSE
134+ <h2 align =" center " >Contributors</h2 >
83135
84- [ MIT] ( LICENSE )
136+ <table >
137+ <tbody >
138+ <tr >
139+ <td align="center">
140+ <img width="150 height="150"
141+ src="https://avatars.githubusercontent.com/u/5419992?v=3&s=150">
142+ <br />
143+ <a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>
144+ </td>
145+ </tr >
146+ <tbody >
147+ </table >
85148
86149[ npm ] : https://img.shields.io/npm/v/gulp-posthtml.svg
87150[ npm-url ] : https://npmjs.com/package/gulp-posthtml
88151
152+ [ node ] : https://img.shields.io/node/v/gulp-posthtml.svg
153+ [ node-url ] : https://nodejs.org/
154+
89155[ deps ] : https://david-dm.org/posthtml/gulp-posthtml.svg
90156[ deps-url ] : https://david-dm.org/posthtml/gulp-posthtml
91157
92- [ build ] : http://img.shields.io/travis/posthtml/gulp-posthtml.svg
93- [ build -url] : https://travis-ci.org/posthtml/gulp-posthtml
158+ [ tests ] : http://img.shields.io/travis/posthtml/gulp-posthtml.svg
159+ [ tests -url] : https://travis-ci.org/posthtml/gulp-posthtml
94160
95161[ cover ] : https://coveralls.io/repos/github/posthtml/gulp-posthtml/badge.svg?branch=master
96162[ cover-url ] : https://coveralls.io/github/posthtml/gulp-posthtml?branch=master
@@ -99,4 +165,4 @@ See [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/docs)
99165[ style-url ] : http://standardjs.com/
100166
101167[ chat ] : https://badges.gitter.im/posthtml/posthtml.svg
102- [ chat-badge ] : https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"
168+ [ chat-url ] : https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"
0 commit comments