Make _.escape match _.template's escape delimiter results for null and undefined values.

Former-commit-id: b6717c6debf3bc308cf12b778916f5a46dbb954d
This commit is contained in:
John-David Dalton
2012-06-11 22:37:54 -04:00
parent 1e2ef542e4
commit 3a698eb0ed
3 changed files with 9 additions and 4 deletions

View File

@@ -525,7 +525,7 @@
*/
function tokenizeEscape(match, value) {
var index = tokenized.length;
tokenized[index] = "'+\n((__t = (" + value + ")) == null ? '' : _.escape(__t)) +\n'";
tokenized[index] = "'+\n_.escape(" + value + ") +\n'";
return token + index;
}
@@ -2985,7 +2985,7 @@
* // => "Curly, Larry & Moe"
*/
function escape(string) {
return (string + '').replace(reUnescapedHtml, escapeHtmlChar);
return string == null ? '' : (string + '').replace(reUnescapedHtml, escapeHtmlChar);
}
/**