forked from esamattis/requirejs-hbs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhbs.js
More file actions
25 lines (18 loc) · 735 Bytes
/
hbs.js
File metadata and controls
25 lines (18 loc) · 735 Bytes
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
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);
// In browsers use the text-plugin to the load template. This way we
// don't have to deal with ajax stuff
parentRequire(["text!" + name + ext], function (raw) {
// Just return the compiled template
onload(Handlebars.compile(raw));
});
}
};
});