mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
merging rlfletchers branch with a safer _.template when the template delimiter includes RegExp characters.
This commit is contained in:
@@ -30,6 +30,9 @@
|
|||||||
// Export the Underscore object for CommonJS.
|
// Export the Underscore object for CommonJS.
|
||||||
if (typeof exports !== 'undefined') exports._ = _;
|
if (typeof exports !== 'undefined') exports._ = _;
|
||||||
|
|
||||||
|
// Quick regexp-escaping function, because JS doesn't have RegExp.escape().
|
||||||
|
var escapeRegExp = function(s) { return s.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1'); };
|
||||||
|
|
||||||
// Create quick reference variables for speed access to core prototypes.
|
// Create quick reference variables for speed access to core prototypes.
|
||||||
var slice = Array.prototype.slice,
|
var slice = Array.prototype.slice,
|
||||||
unshift = Array.prototype.unshift,
|
unshift = Array.prototype.unshift,
|
||||||
@@ -576,7 +579,7 @@
|
|||||||
'var p=[],print=function(){p.push.apply(p,arguments);};' +
|
'var p=[],print=function(){p.push.apply(p,arguments);};' +
|
||||||
'with(obj){p.push(\'' +
|
'with(obj){p.push(\'' +
|
||||||
str.replace(/[\r\t\n]/g, " ")
|
str.replace(/[\r\t\n]/g, " ")
|
||||||
.replace(new RegExp("'(?=[^"+c.end[0]+"]*\\"+c.end.split('').join("\\")+")","g"),"\t")
|
.replace(new RegExp("'(?=[^"+c.end[0]+"]*"+escapeRegExp(c.end)+")","g"),"\t")
|
||||||
.split("'").join("\\'")
|
.split("'").join("\\'")
|
||||||
.split("\t").join("'")
|
.split("\t").join("'")
|
||||||
.replace(c.interpolate, "',$1,'")
|
.replace(c.interpolate, "',$1,'")
|
||||||
|
|||||||
Reference in New Issue
Block a user