-
Notifications
You must be signed in to change notification settings - Fork 21
/
hbs.js
29 lines (21 loc) · 889 Bytes
/
hbs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
define(["handlebars"], function (Handlebars) {
Handlebars = Handlebars || this.Handlebars;
var templateExtension = ".hbs";
return {
pluginBuilder: "./hbs-builder",
// http://requirejs.org/docs/plugins.html#apiload
load: function (name, parentRequire, onload, config) {
// Get the template extension.
var ext = (config.hbs && config.hbs.templateExtension ? config.hbs.templateExtension : templateExtension);
// Get the base path.
var base = (config.hbs && config.hbs.base ? config.hbs.base : null);
var path = base ? base + '/' + name : name;
// In browsers use the text-plugin to the load template. This way we
// don't have to deal with ajax stuff
parentRequire(["text!" + path + ext], function (raw) {
// Just return the compiled template
onload(Handlebars.compile(raw));
});
}
};
});