gulp-file-include
a plugin of gulp for file include
install
npm install gulp-file-include
options
- options - type:
string
, just as prefix, default@@
, and basepath is default@file
-
options - type:
object
- prefix:
string
, default@@
- suffix:
string
, default''
- basepath:
string
, default@file
, it could be@root
,@file
,your-basepath
- filters:
object
, filters of include content - context:
object
, context ofif
statement - indent:
boolean
, defaultfalse
- prefix:
-
options.basepath - type:
string
, it could be@root
, include file relative to the dir wheregulp
running in@file
, include file relative to the dir wherefile
in exampleyour-basepath
include file relative to the basepath you give
example
index.html
@@include('./view.html') @@include('./var.html', { "name": "haoxin", "age": 12345, "socials": { "fb": "facebook.com/include", "tw": "twitter.com/include" } })
view.html
view
var.html
@@name@@age@@socials.fb@@socials.tw
gulpfile.js
var fileinclude = gulp = ; gulp;
and the result is:
view haoxin12345facebook.com/includetwitter.com/include
filters
@@include(markdown('view.md')) @@include('./var.html', { "name": "haoxin", "age": 12345 })
view.md
view====
var fileinclude = markdown = gulp = ; gulp;
if
statement
;
@@include('some.html', { "nav": true })
@@if (name === 'test' && nav === true) {
@@include('test.html')
}
foreach
statement
;
@@foreach (buttons) {
<button name="@@index">@@text</button>
}
License
MIT