gulp-template-compile
Compile Lo-Dash templates (should work with Underscore templates too).
This plugin is heavily inspired by Sindre Sorhus's gulp-nunjucks plugin, in fact I used it as skeleton for creating this one.
Install with npm
npm install --save-dev gulp-template-compile
var gulp = require('gulp');
var template = require('gulp-template-compile');
var concat = require('gulp-concat');
gulp.task('default', function () {
gulp.src('src/*.html')
.pipe(template())
.pipe(concat('templates.js'))
.pipe(gulp.dest('dist'));
});
See the Lo-Dash _.template
docs.
Type: Object
Type: Function
Default: Relative template path. Example: templates/list.html
You can override the default behavior by supplying a function which gets the current File object and is expected to return the name.
Example:
{
name: function (file) {
return 'tpl-' + file.relative;
}
}
Type: String
Default: 'JST'
The namespace in which the precompiled templates will be assigned.
Type: Object
Default: null
If you use grunt instead of gulp, but want to perform a similar task, use grunt-contrib-jst.
MIT © Emanuele Ingrosso