Permalink
Browse files

Merge pull request #29 from thanpolas/0.5-node-require-fix

0.5.x fix for node option.
  • Loading branch information...
2 parents c7a0ed9 + 8634746 commit f7488e76dcfec76265abb7c64aad9290432174f6 @tkellen tkellen committed Feb 22, 2013
Showing with 25 additions and 22 deletions.
  1. +20 −20 Gruntfile.js
  2. +2 −1 tasks/handlebars.js
  3. +3 −1 test/expected/handlebars-node.js
View
@@ -84,26 +84,26 @@ module.exports = function(grunt) {
files: {
'tmp/no_namespace.js': ['test/fixtures/basic.hbs']
}
- },
- processcontent: {
- options: {
- processContent: function(content) {
- content = content.replace(/^[\x20\t]+/mg, '').replace(/[\x20\t]+$/mg, '');
- content = content.replace(/^[\r\n]+/, '').replace(/[\r\n]+$/, '');
- return content;
- }
- },
- files: {
- 'tmp/processcontent.js': ['test/fixtures/has-spaces.hbs']
- }
- },
- amd_compile: {
- options: {
- amd: true
- },
- files: {
- 'tmp/amd_compile.js': ['test/fixtures/amd.html']
- }
+ },
+ processcontent: {
+ options: {
+ processContent: function(content) {
+ content = content.replace(/^[\x20\t]+/mg, '').replace(/[\x20\t]+$/mg, '');
+ content = content.replace(/^[\r\n]+/, '').replace(/[\r\n]+$/, '');
+ return content;
+ }
+ },
+ files: {
+ 'tmp/processcontent.js': ['test/fixtures/has-spaces.hbs']
+ }
+ },
+ amd_compile: {
+ options: {
+ amd: true
+ },
+ files: {
+ 'tmp/amd_compile.js': ['test/fixtures/amd.html']
+ }
},
amd_compile_direct: {
options: {
View
@@ -102,7 +102,8 @@ module.exports = function(grunt) {
output.unshift(nsInfo.declaration);
if (options.node) {
- output.unshift('var Handlebars = Handlebars || require(\'Handlebars\');');
+ output.unshift('Handlebars = glob.Handlebars || require(\'handlebars\');');
+ output.unshift('var glob = (\'undefined\' === typeof window) ? global : window,');
var nodeExport = 'if (typeof exports === \'object\' && exports) {';
nodeExport += 'module.exports = ' + nsInfo.namespace + ';}';
@@ -1,4 +1,6 @@
-var Handlebars = Handlebars || require('Handlebars');
+var glob = ('undefined' === typeof window) ? global : window,
+
+Handlebars = glob.Handlebars || require('handlebars');
this["JST"] = this["JST"] || {};

0 comments on commit f7488e7

Please sign in to comment.