underscore-source 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -38,7 +38,7 @@
|
|
38
38
|
propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
39
39
|
|
40
40
|
// Current version.
|
41
|
-
_.VERSION = '0.5.
|
41
|
+
_.VERSION = '0.5.4';
|
42
42
|
|
43
43
|
// ------------------------ Collection Functions: ---------------------------
|
44
44
|
|
@@ -561,19 +561,19 @@
|
|
561
561
|
|
562
562
|
// JavaScript templating a-la ERB, pilfered from John Resig's
|
563
563
|
// "Secrets of the JavaScript Ninja", page 83.
|
564
|
+
// Single-quote fix from Rick Strahl's version.
|
564
565
|
_.template = function(str, data) {
|
565
566
|
var fn = new Function('obj',
|
566
567
|
'var p=[],print=function(){p.push.apply(p,arguments);};' +
|
567
568
|
'with(obj){p.push(\'' +
|
568
|
-
str
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
+ "');}return p.join('');");
|
569
|
+
str.replace(/[\r\t\n]/g, " ")
|
570
|
+
.replace(/'(?=[^%]*%>)/g,"\t")
|
571
|
+
.split("'").join("\\'")
|
572
|
+
.split("\t").join("'")
|
573
|
+
.replace(/<%=(.+?)%>/g, "',$1,'")
|
574
|
+
.split("<%").join("');")
|
575
|
+
.split("%>").join("p.push('")
|
576
|
+
+ "');}return p.join('');");
|
577
577
|
return data ? fn(data) : fn;
|
578
578
|
};
|
579
579
|
|