mirror of
https://github.com/CryptKeeperZK/ejs.git
synced 2026-01-08 15:13:50 -05:00
Fix breakage from truncation-mode PR
This commit is contained in:
10
lib/ejs.js
10
lib/ejs.js
@@ -576,12 +576,16 @@ Template.prototype = {
|
||||
|
||||
function _addOutput() {
|
||||
if (self.truncate) {
|
||||
line = line
|
||||
.replace(/\r?\n/, '')
|
||||
// Only replace single leading linebreak in the line after
|
||||
// -%> tag -- this is the single, trailing linebreak
|
||||
// after the tag that the truncation mode replaces
|
||||
// Handle Win / Unix / old Mac linebreaks -- do the \r\n
|
||||
// combo first in the regex-or
|
||||
line = line.replace(/^(?:\r\n|\r|\n)/, '')
|
||||
self.truncate = false;
|
||||
}
|
||||
else if (self.opts.rmWhitespace) {
|
||||
// Gotta me more careful here.
|
||||
// Gotta be more careful here.
|
||||
// .replace(/^(\s*)\n/, '$1') might be more appropriate here but as
|
||||
// rmWhitespace already removes trailing spaces anyway so meh.
|
||||
line = line.replace(/^\n/, '');
|
||||
|
||||
@@ -519,7 +519,7 @@ suite('-%>', function () {
|
||||
+ "<% }) -%>\n"
|
||||
+ "</ul><% -%>\n";
|
||||
|
||||
var expectedResult = "<ul><li>geddy</li><li>neil</li><li>alex</li></ul>";
|
||||
var expectedResult = "<ul><li>geddy</li>\n<li>neil</li>\n<li>alex</li>\n</ul>";
|
||||
var fn;
|
||||
fn = ejs.compile(content);
|
||||
assert.equal(fn({users: users}),
|
||||
@@ -533,7 +533,7 @@ suite('-%>', function () {
|
||||
+ "<% }) -%>\r\n"
|
||||
+ "</ul><% -%>\r\n";
|
||||
|
||||
var expectedResult = "<ul><li>geddy</li><li>neil</li><li>alex</li></ul>";
|
||||
var expectedResult = "<ul><li>geddy</li>\r\n<li>neil</li>\r\n<li>alex</li>\r\n</ul>";
|
||||
var fn;
|
||||
fn = ejs.compile(content);
|
||||
assert.equal(fn({users: users}),
|
||||
|
||||
Reference in New Issue
Block a user