X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6a7e4474cba9d8be4b2ec445e10f1691f7277c50..b37ceabb82336ee82757cd32efe353cfab8ec267:/src/ext-core/src/core/Template.js diff --git a/src/ext-core/src/core/Template.js b/src/ext-core/src/core/Template.js index 6c08c502..3c72c131 100644 --- a/src/ext-core/src/core/Template.js +++ b/src/ext-core/src/core/Template.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.2.0 + * Ext JS Library 3.2.2 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license @@ -9,7 +9,7 @@ *

Represents an HTML fragment template. Templates may be {@link #compile precompiled} * for greater performance.

*

For example usage {@link #Template see the constructor}.

- * + * * @constructor * An instance of this class may be created by passing to the constructor either * a single argument, or multiple arguments: @@ -45,7 +45,7 @@ var t = new Ext.Template( { compiled: true, // {@link #compile} immediately disableFormats: true // See Notes below. - } + } ); * *

Notes:

@@ -61,19 +61,21 @@ var t = new Ext.Template( */ Ext.Template = function(html){ var me = this, - a = arguments, - buf = []; + a = arguments, + buf = [], + v; if (Ext.isArray(html)) { html = html.join(""); } else if (a.length > 1) { - Ext.each(a, function(v) { - if (Ext.isObject(v)) { + for(var i = 0, len = a.length; i < len; i++){ + v = a[i]; + if(typeof v == 'object'){ Ext.apply(me, v); } else { buf.push(v); } - }); + }; html = buf.join(''); } @@ -111,14 +113,14 @@ Ext.Template.prototype = { * @return {String} The HTML fragment */ applyTemplate : function(values){ - var me = this; + var me = this; return me.compiled ? - me.compiled(values) : - me.html.replace(me.re, function(m, name){ - return values[name] !== undefined ? values[name] : ""; - }); - }, + me.compiled(values) : + me.html.replace(me.re, function(m, name){ + return values[name] !== undefined ? values[name] : ""; + }); + }, /** * Sets the HTML used as the template and optionally compiles it. @@ -127,7 +129,7 @@ Ext.Template.prototype = { * @return {Ext.Template} this */ set : function(html, compile){ - var me = this; + var me = this; me.html = html; me.compiled = null; return compile ? me.compile() : me; @@ -139,13 +141,13 @@ Ext.Template.prototype = { */ compile : function(){ var me = this, - sep = Ext.isGecko ? "+" : ","; + sep = Ext.isGecko ? "+" : ","; - function fn(m, name){ - name = "values['" + name + "']"; - return "'"+ sep + '(' + name + " == undefined ? '' : " + name + ')' + sep + "'"; + function fn(m, name){ + name = "values['" + name + "']"; + return "'"+ sep + '(' + name + " == undefined ? '' : " + name + ')' + sep + "'"; } - + eval("this.compiled = function(values){ return " + (Ext.isGecko ? "'" : "['") + me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) + (Ext.isGecko ? "';};" : "'].join('');};")); @@ -241,4 +243,4 @@ Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate; Ext.Template.from = function(el, config){ el = Ext.getDom(el); return new Ext.Template(el.value || el.innerHTML, config || ''); -}; \ No newline at end of file +};