mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Merge branch 'patch-1' of http://github.com/shesek/underscore
This commit is contained in:
@@ -816,6 +816,11 @@
|
|||||||
for (var i = 0; i < n; i++) iterator.call(context, i);
|
for (var i = 0; i < n; i++) iterator.call(context, i);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Escape string for HTML
|
||||||
|
_.escape = function(string) {
|
||||||
|
return (''+string).replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
|
||||||
|
};
|
||||||
|
|
||||||
// Add your own custom functions to the Underscore object, ensuring that
|
// Add your own custom functions to the Underscore object, ensuring that
|
||||||
// they're correctly added to the OOP wrapper as well.
|
// they're correctly added to the OOP wrapper as well.
|
||||||
_.mixin = function(obj) {
|
_.mixin = function(obj) {
|
||||||
@@ -836,7 +841,8 @@
|
|||||||
// following template settings to use alternative delimiters.
|
// following template settings to use alternative delimiters.
|
||||||
_.templateSettings = {
|
_.templateSettings = {
|
||||||
evaluate : /<%([\s\S]+?)%>/g,
|
evaluate : /<%([\s\S]+?)%>/g,
|
||||||
interpolate : /<%=([\s\S]+?)%>/g
|
interpolate : /<%=([\s\S]+?)%>/g,
|
||||||
|
encode : /<%==([\s\S]+?)%>/g
|
||||||
};
|
};
|
||||||
|
|
||||||
// JavaScript micro-templating, similar to John Resig's implementation.
|
// JavaScript micro-templating, similar to John Resig's implementation.
|
||||||
@@ -848,6 +854,9 @@
|
|||||||
'with(obj||{}){__p.push(\'' +
|
'with(obj||{}){__p.push(\'' +
|
||||||
str.replace(/\\/g, '\\\\')
|
str.replace(/\\/g, '\\\\')
|
||||||
.replace(/'/g, "\\'")
|
.replace(/'/g, "\\'")
|
||||||
|
.replace(c.encode, function(match, code) {
|
||||||
|
return "',_.escape(" + code.replace(/\\'/g, "'") + "),'";
|
||||||
|
})
|
||||||
.replace(c.interpolate, function(match, code) {
|
.replace(c.interpolate, function(match, code) {
|
||||||
return "'," + code.replace(/\\'/g, "'") + ",'";
|
return "'," + code.replace(/\\'/g, "'") + ",'";
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user