gulp-template

Render/precompile Lo-Dash/Underscore templates

gulp-template

Render/precompile Lo-Dash/Underscore templates

Issues with the output should be reported on the Lo-Dash issue tracker.

$ npm install --save-dev gulp-template
<h1>Hello <%= name %></h1>
var gulp = require('gulp');
var template = require('gulp-template');
 
gulp.task('default', function () {
return gulp.src('src/greeting.html')
.pipe(template({name: 'Sindre'}))
.pipe(gulp.dest('dist'));
});

You can alternatively use gulp-data to inject the data:

var gulp = require('gulp');
var template = require('gulp-template');
var data = require('gulp-data');
 
gulp.task('default', function () {
return gulp.src('src/greeting.html')
.pipe(data(function () {
return {name: 'Sindre'};
}))
.pipe(template())
.pipe(gulp.dest('dist'));
});
<h1>Hello Sindre</h1>

Render a template using the provided data.

Precompile a template for rendering dynamically at a later time.

Type: Object

The data object used to populate the text.

Type: Object

Lo-Dash _.template options.

If you use grunt instead of gulp, but want to perform a similar task, use grunt-template.

MIT © Sindre Sorhus