diff --git a/Gruntfile.js b/Gruntfile.js index d29fe93..2a6e8d5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -74,6 +74,18 @@ module.exports = function(grunt) { "tmp/amd_wrapper.js": ["test/fixtures/template.html"] } }, + amd_wrapper_no_ns: { + options: { + templateSettings: { + variable: 'obj' + }, + amdWrapper:true, + namespace:false + }, + files: { + "tmp/amd_wrapper_no_ns.js": ["test/fixtures/template.html"] + } + }, uglyfile: { options: { templateSettings: { diff --git a/tasks/jst.js b/tasks/jst.js index f2810fd..5a73a25 100644 --- a/tasks/jst.js +++ b/tasks/jst.js @@ -83,7 +83,7 @@ module.exports = function(grunt) { if (options.namespace !== false) { // Namespace has not been explicitly set to false; the AMD // wrapper will return the object containing the template. - output.push(" return " + nsInfo.namespace + ";" + lf); + output.push(" return " + nsInfo.namespace + ";"); } output.push("});"); } diff --git a/test/expected/amd_wrapper.js b/test/expected/amd_wrapper.js index c8902d6..670a27d 100644 --- a/test/expected/amd_wrapper.js +++ b/test/expected/amd_wrapper.js @@ -11,4 +11,5 @@ return __p }; return this["JST"]; + }); \ No newline at end of file diff --git a/test/expected/amd_wrapper_no_ns.js b/test/expected/amd_wrapper_no_ns.js new file mode 100644 index 0000000..26bf450 --- /dev/null +++ b/test/expected/amd_wrapper_no_ns.js @@ -0,0 +1,11 @@ +define(function(){ + +return function(obj) { +var __t, __p = '', __e = _.escape; +__p += '' + +((__t = ( obj.title )) == null ? '' : __t) + +''; +return __p +} + +}); \ No newline at end of file diff --git a/test/expected/pretty_amd.js b/test/expected/pretty_amd.js index 760ed87..67cdff0 100644 --- a/test/expected/pretty_amd.js +++ b/test/expected/pretty_amd.js @@ -5,4 +5,5 @@ define(function(){ this["JST"]["test/fixtures/template.html"] = function(obj) {var __t, __p = '', __e = _.escape;__p += '' +((__t = ( obj.title )) == null ? '' : __t) +'';return __p}; return this["JST"]; + }); \ No newline at end of file diff --git a/test/jst_test.js b/test/jst_test.js index a0323c9..390e0c0 100644 --- a/test/jst_test.js +++ b/test/jst_test.js @@ -6,7 +6,7 @@ exports['jst'] = { var expect, result; - test.expect(9); + test.expect(10); expect = grunt.file.read("test/expected/jst.js"); result = grunt.file.read("tmp/jst.js"); @@ -32,6 +32,10 @@ exports['jst'] = { result = grunt.file.read("tmp/amd_wrapper.js"); test.equal(expect, result, "should wrap the template with define for AMD pattern"); + expect = grunt.file.read("test/expected/amd_wrapper_no_ns.js"); + result = grunt.file.read("tmp/amd_wrapper_no_ns.js"); + test.equal(expect, result, "should wrap the template with define for AMD pattern and return the function itself with no namespace"); + expect = grunt.file.read("test/expected/pretty_amd.js"); result = grunt.file.read("tmp/pretty_amd.js"); test.equal(expect, result, "should make the AMD wrapper output pretty");