</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.2.0
+ * Ext JS Library 3.2.1
* Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
* <p>Represents an HTML fragment template. Templates may be {@link #compile precompiled}
* for greater performance.</p>
* <p>For example usage {@link #Template see the constructor}.</p>
- *
+ *
* @constructor
* An instance of this class may be created by passing to the constructor either
* a single argument, or multiple arguments:
{
compiled: true, // {@link #compile} immediately
disableFormats: true // See Notes below.
- }
+ }
);
* </code></pre>
* <p><b>Notes</b>:</p>
*/
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('');
}
* @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] : "";
+ });
+ },
<div id="method-Ext.Template-set"></div>/**
* Sets the HTML used as the template and optionally compiles it.
* @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;
*/
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('');};"));
Ext.Template.from = function(el, config){
el = Ext.getDom(el);
return new Ext.Template(el.value || el.innerHTML, config || '');
-};</pre>
+};
+</pre>
</body>
</html>
\ No newline at end of file