forked from speced/respec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tmpl.js
20 lines (19 loc) · 808 Bytes
/
tmpl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*global Handlebars*/
define(["handlebars", "text"], function (hb, text) {
var buildMap = {};
return {
load: function (name, req, onLoad, config) {
return text.load(name, req, function (content) {
if (config.isBuild && config.inlineText) buildMap[name] = content;
onLoad(config.isBuild ? content : Handlebars.compile(content));
}, config);
}
, write: function (pluginName, moduleName, write) {
if (moduleName in buildMap) {
var content = text.jsEscape(buildMap[moduleName]);
write("define('" + pluginName + "!" + moduleName +
"', ['handlebars'], function (hb) { return Handlebars.compile('" + content + "');});\n");
}
}
};
});