Skip to content

Additional helper for handlebars, include template into template. Work similar to partials but with browserify

Notifications You must be signed in to change notification settings

ftdebugger/injectify-include

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Injectify include helper Build Status

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

About

Additional helper for handlebars, include template into template. Work similar to partials but with browserify

Resources

Stars

Watchers

Forks

Packages

No packages published