Gulp plugin to compile HTML templates to JavaScript functions using lodash.
In templates/test.html
:
<p>Hello <%= place %></p>
In your gulpfile:
var compiler = require('gulp-lodash-compile');
gulp.task('templates', function() {
gulp.src('templates/**/*.html')
.pipe(compiler('templates.js'));
.pipe(gulp.dest('js/'));
});
In your JavaScript:
var templates = require('js/templates.js');
var html = templates.test({
place: 'world';
})
- file
string
- The name of the file to use for the compiled templates
- options
object
- Options passed to the task
The line delimiter, defaults to your operating system's newline.
Either amd
, commonjs
or false
for no wrapper, defaults to amd
. If wrapper is false
a local var templates
will be defined containing the templates.
A function that will be passed the file and should return a name for the template. By default uses the basename of the file without an extension.
An object to pass to _template function