Skip to content

Commit

Permalink
Better AMD support
Browse files Browse the repository at this point in the history
  • Loading branch information
neiker committed Jul 16, 2014
1 parent 59610f3 commit 3d08a24
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ template-module: {
which would produce `/*jshint unused:false, asi:true, expr:true*/` and add it to the bottom of the file.

#### amdWrapper
Type: ```boolean```
Type: ```boolean``` | ```string```
Default: false

With Require.js and a pre-compiled template.js you want the templates to be
Expand All @@ -198,6 +198,20 @@ options: {
}
```

If you want a specific define, you can provide it as string:
``` javascript
options: {
amdWrapper: 'define("templates", ["i18n"], function(__) {'
}
```
Will result in:
``` javascript
define("templates", ["i18n"], function(__) {
//Templates
return this["NAMESPACE"];
});
```

* This is not used when module is set to true.*


Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"templates"
],
"dependencies": {
"ejs": "^1.0.0",
"lodash": "^2.4.1",
"node-beautify": "0.0.2",
"underscore": "^1.6.0"
"ejs": "~1.0.0",
"lodash": "~2.4.1",
"underscore": "~1.6.0",
"node-beautify": "0.0.2"
},
"devDependencies": {
"grunt": "^0.4.5",
Expand Down
4 changes: 2 additions & 2 deletions tasks/template-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ module.exports = function (grunt) {
}

if (options.amdWrapper) {

output.unshift("define(function(){");
var amdDefine = typeof options.amdWrapper==="string" ? options.amdWrapper : "define(function(){";
output.unshift(amdDefine);
output.push(" return " + nsInfo.namespace + ";\n});");
} else if (options.module) {
output.unshift(["var _ = require('" + options.provider + "');"]);
Expand Down

0 comments on commit 3d08a24

Please sign in to comment.