Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / docs / source / Template-more.html
index fa5a58c..f6a224f 100644 (file)
-<html>\r
-<head>\r
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js">/**\r
- * @class Ext.Template\r
- */\r
-Ext.apply(Ext.Template.prototype, {\r
-    <div id="cfg-Ext.Template-disableFormats"></div>/**\r
-     * @cfg {Boolean} disableFormats Specify <tt>true</tt> to disable format\r
-     * functions in the template. If the template does not contain\r
-     * {@link Ext.util.Format format functions}, setting <code>disableFormats</code>\r
-     * to true will reduce <code>{@link #apply}</code> time. Defaults to <tt>false</tt>.\r
-     * <pre><code>\r
-var t = new Ext.Template(\r
-    '&lt;div name="{id}"&gt;',\r
-        '&lt;span class="{cls}"&gt;{name} {value}&lt;/span&gt;',\r
-    '&lt;/div&gt;',\r
-    {\r
-        compiled: true,      // {@link #compile} immediately\r
-        disableFormats: true // reduce <code>{@link #apply}</code> time since no formatting\r
-    }    \r
-);\r
-     * </code></pre>\r
-     * For a list of available format functions, see {@link Ext.util.Format}.\r
-     */\r
-    disableFormats : false,                            \r
-    <div id="prop-Ext.Template-disableFormats"></div>/**\r
-     * See <code>{@link #disableFormats}</code>.\r
-     * @type Boolean\r
-     * @property disableFormats\r
-     */\r
-\r
-    <div id="prop-Ext.Template-re"></div>/**\r
-     * The regular expression used to match template variables\r
-     * @type RegExp\r
-     * @property\r
-     * @hide repeat doc\r
-     */\r
-    re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,\r
-\r
-    <div id="method-Ext.Template-applyTemplate"></div>/**\r
-     * Returns an HTML fragment of this template with the specified values applied.\r
-     * @param {Object/Array} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})\r
-     * @return {String} The HTML fragment\r
-     * @hide repeat doc\r
-     */\r
-    applyTemplate : function(values){\r
-               var me = this,\r
-                       useF = me.disableFormats !== true,\r
-               fm = Ext.util.Format, \r
-               tpl = me;           \r
-           \r
-        if(me.compiled){\r
-            return me.compiled(values);\r
-        }\r
-        function fn(m, name, format, args){\r
-            if (format && useF) {\r
-                if (format.substr(0, 5) == "this.") {\r
-                    return tpl.call(format.substr(5), values[name], values);\r
-                } else {\r
-                    if (args) {\r
-                        // quoted values are required for strings in compiled templates,\r
-                        // but for non compiled we need to strip them\r
-                        // quoted reversed for jsmin\r
-                        var re = /^\s*['"](.*)["']\s*$/;\r
-                        args = args.split(',');\r
-                        for(var i = 0, len = args.length; i < len; i++){\r
-                            args[i] = args[i].replace(re, "$1");\r
-                        }\r
-                        args = [values[name]].concat(args);\r
-                    } else {\r
-                        args = [values[name]];\r
-                    }\r
-                    return fm[format].apply(fm, args);\r
-                }\r
-            } else {\r
-                return values[name] !== undefined ? values[name] : "";\r
-            }\r
-        }\r
-        return me.html.replace(me.re, fn);\r
-    },\r
-               \r
-    <div id="method-Ext.Template-compile"></div>/**\r
-     * Compiles the template into an internal function, eliminating the RegEx overhead.\r
-     * @return {Ext.Template} this\r
-     * @hide repeat doc\r
-     */\r
-    compile : function(){\r
-        var me = this,\r
-               fm = Ext.util.Format,\r
-               useF = me.disableFormats !== true,\r
-               sep = Ext.isGecko ? "+" : ",",\r
-               body;\r
-        \r
-        function fn(m, name, format, args){\r
-            if(format && useF){\r
-                args = args ? ',' + args : "";\r
-                if(format.substr(0, 5) != "this."){\r
-                    format = "fm." + format + '(';\r
-                }else{\r
-                    format = 'this.call("'+ format.substr(5) + '", ';\r
-                    args = ", values";\r
-                }\r
-            }else{\r
-                args= ''; format = "(values['" + name + "'] == undefined ? '' : ";\r
-            }\r
-            return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";\r
-        }\r
-        \r
-        // branched to use + in gecko and [].join() in others\r
-        if(Ext.isGecko){\r
-            body = "this.compiled = function(values){ return '" +\r
-                   me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +\r
-                    "';};";\r
-        }else{\r
-            body = ["this.compiled = function(values){ return ['"];\r
-            body.push(me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));\r
-            body.push("'].join('');};");\r
-            body = body.join('');\r
-        }\r
-        eval(body);\r
-        return me;\r
-    },\r
-    \r
-    // private function used to call members\r
-    call : function(fnName, value, allValues){\r
-        return this[fnName](value, allValues);\r
-    }\r
-});\r
-Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate; </pre>    \r
-</body>\r
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+/**
+ * @class Ext.Template
+ */
+Ext.apply(Ext.Template.prototype, {
+    <div id="cfg-Ext.Template-disableFormats"></div>/**
+     * @cfg {Boolean} disableFormats Specify <tt>true</tt> to disable format
+     * functions in the template. If the template does not contain
+     * {@link Ext.util.Format format functions}, setting <code>disableFormats</code>
+     * to true will reduce <code>{@link #apply}</code> time. Defaults to <tt>false</tt>.
+     * <pre><code>
+var t = new Ext.Template(
+    '&lt;div name="{id}"&gt;',
+        '&lt;span class="{cls}"&gt;{name} {value}&lt;/span&gt;',
+    '&lt;/div&gt;',
+    {
+        compiled: true,      // {@link #compile} immediately
+        disableFormats: true // reduce <code>{@link #apply}</code> time since no formatting
+    }    
+);
+     * </code></pre>
+     * For a list of available format functions, see {@link Ext.util.Format}.
+     */
+    disableFormats : false,                            
+    <div id="prop-Ext.Template-disableFormats"></div>/**
+     * See <code>{@link #disableFormats}</code>.
+     * @type Boolean
+     * @property disableFormats
+     */
+
+    <div id="prop-Ext.Template-re"></div>/**
+     * The regular expression used to match template variables
+     * @type RegExp
+     * @property
+     * @hide repeat doc
+     */
+    re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
+
+    <div id="method-Ext.Template-applyTemplate"></div>/**
+     * Returns an HTML fragment of this template with the specified values applied.
+     * @param {Object/Array} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
+     * @return {String} The HTML fragment
+     * @hide repeat doc
+     */
+    applyTemplate : function(values){
+               var me = this,
+                       useF = me.disableFormats !== true,
+               fm = Ext.util.Format, 
+               tpl = me;           
+           
+        if(me.compiled){
+            return me.compiled(values);
+        }
+        function fn(m, name, format, args){
+            if (format && useF) {
+                if (format.substr(0, 5) == "this.") {
+                    return tpl.call(format.substr(5), values[name], values);
+                } else {
+                    if (args) {
+                        // quoted values are required for strings in compiled templates,
+                        // but for non compiled we need to strip them
+                        // quoted reversed for jsmin
+                        var re = /^\s*['"](.*)["']\s*$/;
+                        args = args.split(',');
+                        for(var i = 0, len = args.length; i < len; i++){
+                            args[i] = args[i].replace(re, "$1");
+                        }
+                        args = [values[name]].concat(args);
+                    } else {
+                        args = [values[name]];
+                    }
+                    return fm[format].apply(fm, args);
+                }
+            } else {
+                return values[name] !== undefined ? values[name] : "";
+            }
+        }
+        return me.html.replace(me.re, fn);
+    },
+               
+    <div id="method-Ext.Template-compile"></div>/**
+     * Compiles the template into an internal function, eliminating the RegEx overhead.
+     * @return {Ext.Template} this
+     * @hide repeat doc
+     */
+    compile : function(){
+        var me = this,
+               fm = Ext.util.Format,
+               useF = me.disableFormats !== true,
+               sep = Ext.isGecko ? "+" : ",",
+               body;
+        
+        function fn(m, name, format, args){
+            if(format && useF){
+                args = args ? ',' + args : "";
+                if(format.substr(0, 5) != "this."){
+                    format = "fm." + format + '(';
+                }else{
+                    format = 'this.call("'+ format.substr(5) + '", ';
+                    args = ", values";
+                }
+            }else{
+                args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
+            }
+            return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
+        }
+        
+        // branched to use + in gecko and [].join() in others
+        if(Ext.isGecko){
+            body = "this.compiled = function(values){ return '" +
+                   me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
+                    "';};";
+        }else{
+            body = ["this.compiled = function(values){ return ['"];
+            body.push(me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
+            body.push("'].join('');};");
+            body = body.join('');
+        }
+        eval(body);
+        return me;
+    },
+    
+    // private function used to call members
+    call : function(fnName, value, allValues){
+        return this[fnName](value, allValues);
+    }
+});
+Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate; </pre>    
+</body>
 </html>
\ No newline at end of file