0.1.2 • Published 9 years ago

easy-handlebars v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

easy-handlebars

Compilation of Handlebars templates from Gulp made easy.

Install the 'easy-handlebars' module:

npm install easy-handlebars --save-dev

Example.

  • Compile your TPLs with Gulp:
var source = require('vinyl-source-stream');

gulp.task('tpl', function() {
    var opts = {
        // Optimize the following TPLs (use 'data = false' for this TPLs).
        noData: ['login', 'signup', 'forgot-password'],
        // Pass here the Handlebars's compiler options.
        defaultCompilerOpts: { knownHelpersOnly: true, knownHelpers: ['basePath', 'breakLines'] }
    };
    return easyHandlebars('./src/views/partials/*.html', opts)
        .pipe(source('tpl-bundle.js'))
        .pipe(gulp.dest('./public/js'));
});
  • Include the 'Handlebars.runtime.js' library and the resulting .js file of compiling the TPLs in your app.

  • Use your TPLs:

var someTplFileNameTpl = Handlebars.partials['someTplFileName'];
var someTplFileNameHtml = someTplFileNameTpl();
document.getElementById('content').innerHTML = someTplFileNameHtml;
0.1.2

9 years ago

0.1.1

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago