Templating fix for when an escaped character is used in Javascript

If an escaped character (e.g. \n) is used in embedded Javascript inside
a template then it gets escaped to \\n. If someone has put an escaped
character in their JS then they probably want it left that way.

This commit replaces \\s with a single \ when inside evaluation tags,
reverting the previous template escaping.
This commit is contained in:
Stuart Knightley
2011-12-08 11:36:20 -08:00
parent 81cb0d3a86
commit c8ecb47765

View File

@@ -909,7 +909,8 @@
})
.replace(c.evaluate || null, function(match, code) {
return "');" + code.replace(/\\'/g, "'")
.replace(/[\r\n\t]/g, ' ') + ";__p.push('";
.replace(/[\r\n\t]/g, ' ')
.replace(/\\\\/g, '\\') + ";__p.push('";
})
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')