Skip to content

Commit

Permalink
Preserve literal backslashes in EJS raw-text sections.
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Apr 3, 2012
1 parent 30c8ac0 commit 9325af6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/template/adapters/ejs/template.js
Expand Up @@ -171,8 +171,13 @@ ejs.Template.prototype = new function () {
this.scanLine = function (line) {
var _this = this;
var _addOutput = function () {
// Preserve literal slashes
line = line.replace(/\\/g, '\\\\');
// Convert linebreaks
line = line.replace(/\n/, '\\n');
line = line.replace(/\r/, '');
line = line.replace(/\r/, '\\r');
// Escape double-quotes -- this will be the delimiter
// during execution
line = line.replace(/"/g, '\\"');
_this.source += '_output += "' + line + '";';
};
Expand Down

0 comments on commit 9325af6

Please sign in to comment.