You can use include to reference the public HTML, at the mean time input the corresponding parameter to modify the content of the module. The module grammar is based on ejs.
npm install gulp-include-html
var gih = require("gulp-include-html");
gulp.task('build-html' , function(){
return gulp.src("./html-init/**/*.html")
.pipe(gih({
'public':"./public/bizapp" + version,
'version':version,
baseDir:'./html/modules/',
ignore:\/modules\/
}))
.pipe(gulp.dest("./dest"));
});
Before compile.
<div>
@@include('./_value.html' , {
contents:'I am so smart'
})
</div>
_value.html
<span><%= contents%></span>
After compile:
<div>
<span>I am so smart</span>
</div>
The following parameters are all input like gih({xxx:xxx})
.
file's extend name, default is 'html'
It's the base position of the module, if you set up this, you will input all your file in this setup base position as the standard.
For example, when I setting like this : baseDir:"html/module/"
.
My code is : @@include('test');
.
And then the file path will be explained as: html/module/test.html
.
If you set it as: include:'__include__'
the above @@include()
should change to __include__()
.
The ignore file. This value can be string、array、regular.
For example :ignore:"./html-init/modules"
,then the file of modules wouldn't be export.
And it also can be written like this:
ignore:["./html-init/modules" , "./html-init/modules_2"]
or
ignore:/\.\/html-init\/\w+/g
It's the options of ejs.
gih({
ejs : { delimiter:"$" }
})
Ejs tag will be <$= content$>
.