This plugin enables loading Handlebars templates dynamically during development and compile them during build.
Define an template like people.hb
:
Load it with the hb
plugin:
require(['hb!people'], function(people){
var markup = people({
title : 'A list of people',
people : [
{ name: 'hans' },
{ name: 'kim' },
{ name: 'mads' },
]
});
});
The plugins is only required for dynamic load so you can use the r.js
setting stubModules
to remove the text!
and hb!
plugins during build. And to remove unnecessary Handlebars code use pragmasOnSave
and the excludeHandlebars
.
Find example usage on: Efficient JavaScript development in a Java world
Released under the MIT license.
This plugin is heavily inspired by the RequireJS Hogan Plugin