JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9093
  • Score
    100M100P100Q138828F
  • License MIT

Compile Handlebars templates to file - gulp plugin

Package Exports

  • gulp-compile-handlebars

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-compile-handlebars) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gulp-compile-handlebars

Forked from gulp-template Inspired by grunt-compile-handlebars

Compile Handlebars templates

Install

Install with npm

npm install --save-dev gulp-compile-handlebars

Example

src/hello.handlebars

<h1>Hello {{firstName}}</h1>
<h2>HELLO! {{capitals firstName}}</h2>
{{> footer}}
{{> footer2}}

gulpfile.js

var gulp = require('gulp');
var handlebars = require('gulp-compile-handlebars');

gulp.task('default', function () {
    var templateData = {
        firstName: 'Kaanon'
    },
    options = {
        ignorePartials: true, //ignores the unknown footer2 partial in the handlebars template, defaults to false
        partials : {
            footer : '<footer>the end</footer>'
        },
        helpers : {
            capitals : function(str){
                return str.toUpperCase();	
            }
        }
    }

    return gulp.src('src/hello.handlebars')
        .pipe(handlebars(templateData, options))
        .pipe(rename('hello.html'))
        .pipe(gulp.dest('dist'));
});

dist/hello.html

<h1>Hello Kaanon</h1>
<h2>HELLO! KAANON</h2>
<footer>the end</footer>

Options

  • ignorePartials : ignores any unknown partials. Useful if you only want to handle part of the file
  • partials : Javascript object that will fill in partials using strings
  • batch : Javascript array of filepaths to use as partials
  • helpers: javascript functions to stand in for helpers used in the handlebars files

License

MIT © Kaanon MacFarlane