diff --git a/tasks/lib/compiler.js b/tasks/lib/compiler.js index 619f40d..31bb97b 100644 --- a/tasks/lib/compiler.js +++ b/tasks/lib/compiler.js @@ -15,8 +15,8 @@ module.exports.init = function(grunt) { var concat = function(options, files, callback) { grunt.util.async.concatSeries(files, function(file, next) { var id = (options.prepend || '') + path.relative(options.base || '.', file).replace( /\\/g, '/'); - var template = '\n $templateCache.put("<%= id %>",\n "<%= content %>"\n );\n'; - var cleaned = grunt.file.read(file).replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\r?\n/g, '" +\n "'); + var template = '\n $templateCache.put("<%= id %>",\n <%= content %>\n );\n'; + var cleaned = grunt.file.read(file).split(/^/gm).map(function(line) { return JSON.stringify(line); }).join(' +\n '); var cached = process(template, id, cleaned); next(null, cached); diff --git a/test/expected/multiple.js b/test/expected/multiple.js index e665c43..6f1d8fe 100644 --- a/test/expected/multiple.js +++ b/test/expected/multiple.js @@ -1,23 +1,21 @@ angular.module("multiple").run(["$templateCache", function($templateCache) { $templateCache.put("multiple/one.html", - "
I am one.
" + - "" + - "" + - "" + "I am one.
\n" + + "\n" + + "\n" ); $templateCache.put("multiple/two/two.html", - "We are two.
" + - "" + "We are two.
\n" ); }]); diff --git a/test/expected/options_module.js b/test/expected/options_module.js index 6659f41..78f6995 100644 --- a/test/expected/options_module.js +++ b/test/expected/options_module.js @@ -1,8 +1,7 @@ angular.module("ImAModuleNotATarget").run(["$templateCache", function($templateCache) { $templateCache.put("simple.html", - "Howdy there! \\ Your name is \"{{ name }}\"." + - "" + "Howdy there! \\ Your name is \"{{ name }}\".\n" ); }]); diff --git a/test/expected/simple.js b/test/expected/simple.js index 97997d7..6487862 100644 --- a/test/expected/simple.js +++ b/test/expected/simple.js @@ -1,8 +1,7 @@ angular.module("simple").run(["$templateCache", function($templateCache) { $templateCache.put("simple.html", - "Howdy there! \\ Your name is \"{{ name }}\"." + - "" + "Howdy there! \\ Your name is \"{{ name }}\".\n" ); }]); diff --git a/test/expected/simple_prepend.js b/test/expected/simple_prepend.js index 3e29ae7..a8e9858 100644 --- a/test/expected/simple_prepend.js +++ b/test/expected/simple_prepend.js @@ -1,8 +1,7 @@ angular.module("prepend").run(["$templateCache", function($templateCache) { $templateCache.put("/prepend/simple.html", - "Howdy there! \\ Your name is \"{{ name }}\"." + - "" + "Howdy there! \\ Your name is \"{{ name }}\".\n" ); }]);