injectify-include
v2.0.2
Published
Include helper for handlebars and browserify
Downloads
2
Readme
Injectify include helper
Additional helper for handlebars, include template into template. Work similar to partials but with browserify
.
Install
npm install --save-dev injectify injectify-include
Usage
Configure gulp
:
var gulp = require("gulp"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
require("injectify-include/inject");
gulp.task('js', function () {
var bundleStream = browserify('./src/index.js')
.transform(require("injectify"))
.bundle();
return bundleStream
.pipe(source('index.js'))
.pipe(gulp.dest('dist'));
});
In file ./src/index.js
require injectify include
helper:
require("injectify-include");
Now you can use include
helper in your templates:
<h1>Example</h1>
<p>{{include "./other-template.hbs"}}</p>
<p>You also may pass params to template</p>
<p>{{include "./other-template.hbs" value=123 id=userId}}</p>
include
helper works like original browserify require
. You can require modules relative to template file or
node_modules directory.
Changelog
v2.0
- Handlebars 3.0
- Injectify 2.0