gulp-html-handlebars
Forked from gulp-template. This fork does not depend on handlebars anymore.
Compile Handlebars templates
Install
Install with npm
npm install --save-dev handlebars gulp-handlebars-html
Example
src/hello.handlebars
{{> partials/header}}<p>Hello {{firstName}}</p><p>HELLO! {{capitals firstName}}</p>{{> footer}}
src/partials/header.handlebars
<h1>Header</h1>
gulpfile.js
var gulp = ;var handlebars = ;var gulpHandlebars = handlebars; //default to require('handlebars') if not providedvar rename = ; handlebars;handlebars; gulp;
dist/hello.html
HeaderHello KaanonHELLO! KAANONthe end
Options
- allowedExtensions (['hb', 'hbs', 'handlebars', 'html']) : Array of allowed extensions for templates
- partialsDirectory ([]) : Array of filepaths to use as partials
Works with gulp-data
Use gulp-data to pass a data object to the template based on the handlebars file being processed. If you pass in template data this will be extended with the object from gulp-data.
See gulp-data for usage examples.
License
MIT