Fix single-line heredocs starting with "undefined"

This commit is contained in:
Simon Lydell 2015-02-18 17:40:40 +01:00
parent dc8a2b17d0
commit 4503e2716e
3 changed files with 7 additions and 2 deletions

View File

@ -242,7 +242,9 @@
if (i === $) {
value = value.replace(TRAILING_BLANK_LINE, '');
}
value = value.replace(indentRegex, '');
if (indentRegex) {
value = value.replace(indentRegex, '');
}
return value;
};
})(this));

View File

@ -217,7 +217,7 @@ exports.Lexer = class Lexer
value = @formatString value
value = value.replace LEADING_BLANK_LINE, '' if i is 0
value = value.replace TRAILING_BLANK_LINE, '' if i is $
value = value.replace indentRegex, ''
value = value.replace indentRegex, '' if indentRegex
value
else
@mergeInterpolationTokens tokens, {delimiter}, (value, i) =>

View File

@ -342,6 +342,9 @@ eq """ "\\\" """, ' "\\" '
eq ''' <- keep these spaces -> ''', ' <- keep these spaces -> '
eq '''undefined''', 'undefined'
eq """undefined""", 'undefined'
test "#1046, empty string interpolations", ->
eq "#{ }", ''