gulp-tpl
[data(yaml/json)] + [data(gulp control)] + [filter(js)] + tpl(handlebars/ejs) -> html
1 tpl -> [1..n] html
State
Usage
Note
-
data file:
demo.yaml / demo.json
-
filter file:
demo.filter.js
-
tpl file:
demo.hbs / demo.ejs
-
note1: base name is same
demo
-
note2: must
*.filter.js
data + tpl -> html
- gulpfile.js
var gulp = ;var savefile = ;var tpl = ; gulp;
- demo.yaml
name: world
- demo.hbs
{{name}}
- output: demo.html
world
data + filter + tpl -> html
- gulpfile.js
var gulp = ;var savefile = ;var tpl = ; gulp;
- demo.yaml
name: world
- demo.filter.js
moduleexports { dataname = "hello " + dataname; return data;};
- demo.hbs
{{name}}
- output: demo.html
hello world
data + gulp + filter + tpl -> html
- gulpfile.js
var gulp = ;var savefile = ;var tpl = ; gulp;
- demo.yaml
v1: from yaml
- demo.filter.js
moduleexports { datav3 = "from filter"; return data;};
- demo.hbs
v1 {{v1}}v2 {{v2}}v3 {{v3}}
- output: demo.html
v1 from yamlv2 from gulpv3 from filter
1 tpl -> [1..n] html
- gulpfile.js
var gulp = ;var savefile = ;var tpl = ; gulp;
- demo.filter.js
moduleexports { datas = ; dataispc = true; datas; data = JSON dataispc = false; datas; return datas;};
- demo.hbs
{{#if ispc}}pc{{else}}mobile{{/if}}
- output: demo_pc.html
pc
- output: demo_mobile.html
mobile
option
- ignoreErr
ignore error, only log error msg, easy to watch and debug
var gulp = ;var savefile = ;var tpl = ; gulp;
Test
npm test
- examples
./test
License
MIT License