Skip to content

Commit

Permalink
Fix travis test checks for #160
Browse files Browse the repository at this point in the history
  • Loading branch information
bzin committed Jan 11, 2016
1 parent d9e2aa9 commit 42d31db
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ options: {
var names = filename.replace(/modules\/(.*)(\/\w+\.hbs)/, '$1');
return names.split('/').join('.');
},
},
files: {
'ns_nested_tmpls.js' : [ 'modules/**/*.hbs']
files: {
'ns_nested_tmpls.js' : [ 'modules/**/*.hbs']
}
}
```

Expand Down Expand Up @@ -101,7 +101,6 @@ define(['handlebars'], function(Handlebars) {
return this['[template namespace]'];
});
```

#### amdDefinitionName
Type: `String`
Default: `false`
Expand Down Expand Up @@ -293,4 +292,4 @@ handlebars: {

Task submitted by [Tim Branyen](http://tbranyen.com)

*This file was generated on Fri Oct 16 2015 18:59:59.*
*This file was generated on Mon Jan 11 2016 01:11:22.*
5 changes: 5 additions & 0 deletions docs/handlebars-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ define(['handlebars'], function(Handlebars) {
return this['[template namespace]'];
});
```
## amdDefinitionName
Type: `String`
Default: `false`

This option gives a name to the AMD module. It is necessary to have amd true.

## commonjs
Type: `Boolean`
Expand Down
28 changes: 15 additions & 13 deletions tasks/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,27 @@ module.exports = function(grunt) {
}

// Start to wrap file with AMD
if (options.amd) {
// addd AMD name string from options.amdDefinitionName
var amdNameString = "";
if (options.amd) {

// add AMD name string from options.amdDefinitionName
var amdNameString = '';

// Verify if it was set a name to define method and its a string
if(options.amdDefinitionName && typeof options.amdDefinitionName === 'string'){
amdNameString = '\''+options.amdDefinitionName+'\',';
}else{
amdNameString = '';
}
if (options.amdDefinitionName && typeof options.amdDefinitionName === 'string') {
amdNameString = '\'' + options.amdDefinitionName + '\',';
} else {
amdNameString = '';
}

// Wrap the file in an AMD define fn.
if (typeof options.amd === 'boolean') {
output.unshift('define('+amdNameString+'[\'handlebars\'], function(Handlebars) {');
output.unshift('define(' + amdNameString + '[\'handlebars\'], function(Handlebars) {');
} else if (typeof options.amd === 'string') {
output.unshift('define('+amdNameString+'[\'' + options.amd + '\'], function(Handlebars) {');
output.unshift('define(' + amdNameString + '[\'' + options.amd + '\'], function(Handlebars) {');
} else if (typeof options.amd === 'function') {
output.unshift('define('+amdNameString+'[\'' + options.amd(filename, ast, compiled) + '\'], function(Handlebars) {');
//jscs:disable maximumLineLength
output.unshift('define(' + amdNameString + '[\'' + options.amd(filename, ast, compiled) + '\'], function(Handlebars) {');
//jscs:enable maximumLineLength
} else if (Array.isArray(options.amd)) {
// convert options.amd to a string of dependencies for require([...])
var amdString = '';
Expand All @@ -217,7 +220,7 @@ module.exports = function(grunt) {
}

// Wrap the file in an AMD define fn.
output.unshift('define('+amdNameString+'[' + amdString + '], function(Handlebars) {');
output.unshift('define(' + amdNameString + '[' + amdString + '], function(Handlebars) {');
}

if (useNamespace) {
Expand All @@ -227,7 +230,6 @@ module.exports = function(grunt) {
}
output.push('});');
}
// End of AMD

if (options.commonjs) {
if (useNamespace) {
Expand Down

0 comments on commit 42d31db

Please sign in to comment.