underscore-source 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Underscore
2
2
  module Source
3
- VERSION = "0.5.5"
3
+ VERSION = "0.5.7"
4
4
  end
5
5
  end
@@ -1,10 +1,10 @@
1
1
  // Underscore.js
2
- // (c) 2009 Jeremy Ashkenas, DocumentCloud Inc.
2
+ // (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
3
3
  // Underscore is freely distributable under the terms of the MIT license.
4
4
  // Portions of Underscore are inspired by or borrowed from Prototype.js,
5
5
  // Oliver Steele's Functional, and John Resig's Micro-Templating.
6
6
  // For all details and documentation:
7
- // http://documentcloud.github.com/underscore/
7
+ // http://documentcloud.github.com/underscore
8
8
 
9
9
  (function() {
10
10
 
@@ -38,7 +38,7 @@
38
38
  propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
39
39
 
40
40
  // Current version.
41
- _.VERSION = '0.5.5';
41
+ _.VERSION = '0.5.7';
42
42
 
43
43
  // ------------------------ Collection Functions: ---------------------------
44
44
 
@@ -488,7 +488,7 @@
488
488
 
489
489
  // Is a given variable an arguments object?
490
490
  _.isArguments = function(obj) {
491
- return obj && _.isNumber(obj.length) && !_.isArray(obj) && !propertyIsEnumerable.call(obj, 'length');
491
+ return obj && _.isNumber(obj.length) && !obj.concat && !obj.substr && !obj.apply && !propertyIsEnumerable.call(obj, 'length');
492
492
  };
493
493
 
494
494
  // Is a given value a function?
@@ -503,7 +503,7 @@
503
503
 
504
504
  // Is a given value a number?
505
505
  _.isNumber = function(obj) {
506
- return toString.call(obj) === '[object Number]';
506
+ return (obj === +obj) || (toString.call(obj) === '[object Number]');
507
507
  };
508
508
 
509
509
  // Is a given value a date?
@@ -559,20 +559,29 @@
559
559
  return prefix ? prefix + id : id;
560
560
  };
561
561
 
562
+ // By default, Underscore uses ERB-style template delimiters, change the
563
+ // following template settings to use alternative delimiters.
564
+ _.templateSettings = {
565
+ start : '<%',
566
+ end : '%>',
567
+ interpolate : /<%=(.+?)%>/g
568
+ };
569
+
562
570
  // JavaScript templating a-la ERB, pilfered from John Resig's
563
571
  // "Secrets of the JavaScript Ninja", page 83.
564
572
  // Single-quote fix from Rick Strahl's version.
565
573
  _.template = function(str, data) {
574
+ var c = _.templateSettings;
566
575
  var fn = new Function('obj',
567
576
  'var p=[],print=function(){p.push.apply(p,arguments);};' +
568
577
  'with(obj){p.push(\'' +
569
578
  str.replace(/[\r\t\n]/g, " ")
570
- .replace(/'(?=[^%]*%>)/g,"\t")
579
+ .replace(new RegExp("'(?=[^"+c.end[0]+"]*"+c.end+")","g"),"\t")
571
580
  .split("'").join("\\'")
572
581
  .split("\t").join("'")
573
- .replace(/<%=(.+?)%>/g, "',$1,'")
574
- .split("<%").join("');")
575
- .split("%>").join("p.push('")
582
+ .replace(c.interpolate, "',$1,'")
583
+ .split(c.start).join("');")
584
+ .split(c.end).join("p.push('")
576
585
  + "');}return p.join('');");
577
586
  return data ? fn(data) : fn;
578
587
  };
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: underscore-source
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.5
5
+ version: 0.5.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel X. Moore