diff --git a/source/extensions.js b/source/extensions.js index 86758d5..e6bbc8b 100644 --- a/source/extensions.js +++ b/source/extensions.js @@ -1,5 +1,145 @@ -// NOTE Having issues conflicting with jQuery stuff when setting Object -// prototype settings; instead add into Liquid.Object.extensions and use in +// Array.indexOf +if (!Array.prototype.indexOf) { + Object.defineProperty(Array.prototype, 'indexOf', { + enumerable: false, + value: function(obj) { + for (var i=0; i= 0; + for (var i = 0; i < len; i++) { + if (arg == this[i]) return true; + } + + return false; + } + }); +} + +// String.capitalize +if (!String.prototype.capitalize) { + String.prototype.capitalize = function() { + return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); + }; +} + +// String.strip +if (!String.prototype.strip) { + String.prototype.strip = function() { + return this.replace(/^\s+/, '').replace(/\s+$/, ''); + }; +} + + +// NOTE Having issues conflicting with jQuery stuff when setting Object +// prototype settings; instead add into Liquid.Object.extensions and use in // the particular location; can add into Object.prototype later if we want. Liquid.extensions = {}; Liquid.extensions.object = {};