diff --git a/lib/jammit/compressor.rb b/lib/jammit/compressor.rb
index 7d624316..74a315fb 100644
--- a/lib/jammit/compressor.rb
+++ b/lib/jammit/compressor.rb
@@ -98,7 +98,7 @@ def compile_jst(paths)
base_path = find_base_path(paths)
compiled = paths.map do |path|
contents = read_binary_file(path)
- contents = contents.gsub(/\n/, '').gsub("'", '\\\\\'')
+ contents = contents.gsub(/\n/, "\\n").gsub("'", '\\\\\'')
name = template_name(path, base_path)
"#{namespace}['#{name}'] = #{Jammit.template_function}('#{contents}');"
end
diff --git a/test/fixtures/jammed/js_test_with_templates.js b/test/fixtures/jammed/js_test_with_templates.js
index b5c5bc47..7b2ea7d4 100644
--- a/test/fixtures/jammed/js_test_with_templates.js
+++ b/test/fixtures/jammed/js_test_with_templates.js
@@ -1 +1 @@
-var myself={sayHi:function(a){console.log("hello, "+a)}};var mandelay={name:function(){return this.constructor.prototype}};myself.sayHi(mandelay.name());(function(){window.JST=window.JST||{};var a=function(c){var b=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+c.replace(/[\r\t\n]/g," ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');");return b};window.JST.template1=a('<%= saying_something %>');window.JST.template2=a('<% _([1,2,3]).each(function(num) { %>
<%= num %> <% }) %>')})();
\ No newline at end of file
+var myself={sayHi:function(a){console.log("hello, "+a)}};var mandelay={name:function(){return this.constructor.prototype}};myself.sayHi(mandelay.name());(function(){window.JST=window.JST||{};var a=function(c){var b=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+c.replace(/[\r\t\n]/g," ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');");return b};window.JST.template1=a('<%= saying_something %>');window.JST.template2=a('<% _([1,2,3]).each(function(num) { %>\n \n <%= num %>\n \n<% }) %>')})();
\ No newline at end of file
diff --git a/test/fixtures/jammed/jst_test-custom-namespace.js b/test/fixtures/jammed/jst_test-custom-namespace.js
index 02709fc1..d3b226c6 100644
--- a/test/fixtures/jammed/jst_test-custom-namespace.js
+++ b/test/fixtures/jammed/jst_test-custom-namespace.js
@@ -2,5 +2,5 @@
custom_namespace = custom_namespace || {};
var template = function(str){var fn = new Function('obj', 'var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push(\''+str.replace(/[\r\t\n]/g, " ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');"); return fn;};
custom_namespace['template1'] = template('<%= saying_something %>');
-custom_namespace['template2'] = template('<% _([1,2,3]).each(function(num) { %> <%= num %> <% }) %>');
+custom_namespace['template2'] = template('<% _([1,2,3]).each(function(num) { %>\n \n <%= num %>\n \n<% }) %>');
})();
\ No newline at end of file
diff --git a/test/fixtures/jammed/jst_test.js b/test/fixtures/jammed/jst_test.js
index a6716fb7..bce5a45d 100644
--- a/test/fixtures/jammed/jst_test.js
+++ b/test/fixtures/jammed/jst_test.js
@@ -2,5 +2,5 @@
window.JST = window.JST || {};
var template = function(str){var fn = new Function('obj', 'var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push(\''+str.replace(/[\r\t\n]/g, " ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');"); return fn;};
window.JST['template1'] = template('<%= saying_something %>');
-window.JST['template2'] = template('<% _([1,2,3]).each(function(num) { %> <%= num %> <% }) %>');
+window.JST['template2'] = template('<% _([1,2,3]).each(function(num) { %>\n \n <%= num %>\n \n<% }) %>');
})();
\ No newline at end of file
diff --git a/test/fixtures/jammed/jst_test_nested.js b/test/fixtures/jammed/jst_test_nested.js
index 4a6d102f..2de1263b 100644
--- a/test/fixtures/jammed/jst_test_nested.js
+++ b/test/fixtures/jammed/jst_test_nested.js
@@ -3,7 +3,7 @@ window.JST = window.JST || {};
var template = function(str){var fn = new Function('obj', 'var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push(\''+str.replace(/[\r\t\n]/g, " ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');"); return fn;};
window.JST['nested/double_nested/double_nested'] = template('<%= hello_world %>
');
window.JST['nested/nested1'] = template('<%= saying_something %>');
-window.JST['nested/nested2'] = template('<% _([1,2,3]).each(function(num) { %> <%= num %> <% }) %>');
+window.JST['nested/nested2'] = template('<% _([1,2,3]).each(function(num) { %>\n \n <%= num %>\n \n<% }) %>');
window.JST['template1'] = template('<%= saying_something %>');
-window.JST['template2'] = template('<% _([1,2,3]).each(function(num) { %> <%= num %> <% }) %>');
+window.JST['template2'] = template('<% _([1,2,3]).each(function(num) { %>\n \n <%= num %>\n \n<% }) %>');
})();
\ No newline at end of file
diff --git a/test/unit/test_configuration.rb b/test/unit/test_configuration.rb
index 4f9c2ff4..b717fc2c 100644
--- a/test/unit/test_configuration.rb
+++ b/test/unit/test_configuration.rb
@@ -73,4 +73,5 @@ def test_environment_specific_configuration
Object.send(:remove_const, :RAILS_ENV)
Object.const_set :RAILS_ENV, "test"
end
+
end