Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
[data(yaml/json)] + [data(gulp control)] + [filter(js)] + tpl(handlebars/ejs) -> [1..n]html
[data(yaml/json)] + [data(gulp control)] + [filter(js)] + tpl(handlebars/ejs) -> html
1 tpl -> [1..n] html
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
var gulp = require('gulp');
var savefile = require('gulp-savefile');
var tpl = require('gulp-tpl');
gulp.task('default', function() {
return gulp.src('demo.hbs') // or demo.ejs/demo.filter.js/demo.yaml/demo.json
.pipe(tpl.html())
.pipe(savefile());
});
name: world
<div>{{name}}</div>
<div>world</div>
var gulp = require('gulp');
var savefile = require('gulp-savefile');
var tpl = require('gulp-tpl');
gulp.task('default', function() {
return gulp.src('demo.hbs') // or demo.ejs/demo.filter.js/demo.yaml/demo.json
.pipe(tpl.html())
.pipe(savefile());
});
name: world
module.exports.filter = function(data) {
data.name = "hello " + data.name;
return data;
};
<div>{{name}}</div>
<div>hello world</div>
var gulp = require('gulp');
var savefile = require('gulp-savefile');
var tpl = require('gulp-tpl');
gulp.task('default', function() {
return gulp.src('demo.hbs') // or demo.ejs/demo.filter.js/demo.yaml/demo.json
.pipe(tpl.html({data:{v2:"from gulp"}}))
.pipe(savefile());
});
v1: from yaml
module.exports.filter = function(data) {
data.v3 = "from filter";
return data;
};
<div>v1 {{v1}}</div>
<div>v2 {{v2}}</div>
<div>v3 {{v3}}</div>
<div>v1 from yaml</div>
<div>v2 from gulp</div>
<div>v3 from filter</div>
var gulp = require('gulp');
var savefile = require('gulp-savefile');
var tpl = require('gulp-tpl');
gulp.task('default', function() {
return gulp.src('demo.hbs') // or demo.ejs/demo.filter.js/demo.yaml/demo.json
.pipe(tpl.html())
.pipe(savefile());
});
module.exports.filter = function(data) {
datas = [];
data.ispc = true;
datas.push({filename:"demo_pc", data:data});
data = JSON.parse(JSON.stringify(data))
data.ispc = false;
datas.push({filename:"demo_mobile", data:data});
return datas;
};
{{#if ispc}}
<div>pc</div>
{{else}}
<div>mobile</div>
{{/if}}
<div>pc</div>
<div>mobile</div>
ignore error, only log error msg, easy to watch and debug
var gulp = require('gulp');
var savefile = require('gulp-savefile');
var tpl = require('gulp-tpl');
gulp.task('default', function() {
return gulp.src('demo.hbs')
.pipe(tpl.html({ignoreErr:true}))
.pipe(savefile());
});
npm test
./test
MIT License
FAQs
[data(yaml/json)] + [data(gulp control)] + [filter(js)] + tpl(handlebars/ejs) -> [1..n]html
We found that gulp-tpl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.