@@ -60,6 +60,7 @@ module.exports = function(grunt) {
6060 separator : grunt . util . linefeed + grunt . util . linefeed ,
6161 wrapped : true ,
6262 amd : false ,
63+ amdDefinitionName : false ,
6364 commonjs : false ,
6465 knownHelpers : [ ] ,
6566 knownHelpersOnly : false
@@ -185,14 +186,25 @@ module.exports = function(grunt) {
185186
186187 }
187188
188- if ( options . amd ) {
189+ // Start to wrap file with AMD
190+ if ( options . amd ) {
191+ // addd AMD name string from options.amdDefinitionName
192+ var amdNameString = "" ;
193+
194+ // Verify if it was set a name to define method and its a string
195+ if ( options . amdDefinitionName && typeof options . amdDefinitionName === 'string' ) {
196+ amdNameString = '\'' + options . amdDefinitionName + '\',' ;
197+ } else {
198+ amdNameString = '' ;
199+ }
200+
189201 // Wrap the file in an AMD define fn.
190202 if ( typeof options . amd === 'boolean' ) {
191- output . unshift ( 'define([\'handlebars\'], function(Handlebars) {' ) ;
203+ output . unshift ( 'define(' + amdNameString + ' [\'handlebars\'], function(Handlebars) {') ;
192204 } else if ( typeof options . amd === 'string' ) {
193- output . unshift ( 'define([\'' + options . amd + '\'], function(Handlebars) {' ) ;
205+ output . unshift ( 'define(' + amdNameString + ' [\'' + options . amd + '\'], function(Handlebars) {' ) ;
194206 } else if ( typeof options . amd === 'function' ) {
195- output . unshift ( 'define([\'' + options . amd ( filename , ast , compiled ) + '\'], function(Handlebars) {' ) ;
207+ output . unshift ( 'define(' + amdNameString + ' [\'' + options . amd ( filename , ast , compiled ) + '\'], function(Handlebars) {' ) ;
196208 } else if ( Array . isArray ( options . amd ) ) {
197209 // convert options.amd to a string of dependencies for require([...])
198210 var amdString = '' ;
@@ -205,7 +217,7 @@ module.exports = function(grunt) {
205217 }
206218
207219 // Wrap the file in an AMD define fn.
208- output . unshift ( 'define([' + amdString + '], function(Handlebars) {' ) ;
220+ output . unshift ( 'define(' + amdNameString + ' [' + amdString + '], function(Handlebars) {' ) ;
209221 }
210222
211223 if ( useNamespace ) {
@@ -215,6 +227,7 @@ module.exports = function(grunt) {
215227 }
216228 output . push ( '});' ) ;
217229 }
230+ // End of AMD
218231
219232 if ( options . commonjs ) {
220233 if ( useNamespace ) {
0 commit comments