diff --git a/test/utility.js b/test/utility.js index c9498c227..7673eadfa 100644 --- a/test/utility.js +++ b/test/utility.js @@ -59,6 +59,10 @@ $(document).ready(function() { result = fancyTemplate({people : {moe : "Moe", larry : "Larry", curly : "Curly"}}); equals(result, "", 'can run arbitrary javascript in templates'); + var noInterpolateTemplate = _.template("

Just some text. Hey, I know this is silly but it aids consistency.

"); + result = noInterpolateTemplate(); + equals(result, "

Just some text. Hey, I know this is silly but it aids consistency.

"); + var quoteTemplate = _.template("It's its, not it's"); equals(quoteTemplate({}), "It's its, not it's"); diff --git a/underscore.js b/underscore.js index 1170caf8d..b0533cadc 100644 --- a/underscore.js +++ b/underscore.js @@ -625,7 +625,7 @@ var endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g"); var fn = new Function('obj', 'var p=[],print=function(){p.push.apply(p,arguments);};' + - 'with(obj){p.push(\'' + + 'with(obj||{}){p.push(\'' + str.replace(/[\r\t\n]/g, " ") .replace(endMatch,"\t") .split("'").join("\\'")