-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
It would be great if the option.amd was working similarly as in the grunt-contrib-handlebars (since it's very similar) This would enable users to define the library name right in the template init function..
gruntfile.json
amd: ['my_underscore'],
jst.js
if (typeof options.amd === 'boolean') {
output.unshift("define(function(){");
} else if (typeof options.amd === 'string') {
output.unshift('define([\'' + options.amd + '\'], function(_) {');
} else if (Array.isArray(options.amd)) {
// convert options.amd to a string of dependencies for require([...])
var amdString = '';
for (var i = 0; i < options.amd.length; i++) {
if (i !== 0) {
amdString += ', ';
}
amdString += '\'' + options.amd[i] + '\'';
}
output.unshift('define([' + amdString + '], function(_) {');
}
result:
define(['my_underscore'], function(_) {
this["test"] = this["test"] || {};
this["test"]["test1"] = function(obj) {
var __t, __p = '', __e = _.escape;
__p += '<head><title>' +
((__t = ( obj.title )) == null ? '' : __t) +
'</title></head>';
return __p
};
return this["test"];
});
Metadata
Metadata
Assignees
Labels
No labels