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>
const gulp = require('gulp');
const template = require('gulp-template');
gulp.task('default', () =>
gulp.src('src/greeting.html')
.pipe(template({name: 'Sindre'}))
.pipe(gulp.dest('dist'))
);
You can alternatively use gulp-data to inject the data:
const gulp = require('gulp');
const template = require('gulp-template');
const data = require('gulp-data');
gulp.task('default', () =>
gulp.src('src/greeting.html')
.pipe(data(() => ({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
Data object used to populate the text.
Type: object
- grunt-template - Grunt version
MIT © Sindre Sorhus