Roo/Template.js
authorAlan Knowles <alan@akbkhome.com>
Wed, 28 Jul 2010 04:54:47 +0000 (12:54 +0800)
committerAlan Knowles <alan@akbkhome.com>
Wed, 28 Jul 2010 04:54:47 +0000 (12:54 +0800)
Roo/Template.js

index 597f93a..3b9d6a3 100644 (file)
@@ -15,7 +15,8 @@
 * For a list of available format functions, see {@link Roo.util.Format}.<br />
 * Usage:
 <pre><code>
 * For a list of available format functions, see {@link Roo.util.Format}.<br />
 * Usage:
 <pre><code>
-var t = new Roo.Template(
+var t = new Roo.Template({
+    * html : 
     '&lt;div name="{id}"&gt;',
         '&lt;span class="{cls}"&gt;{name:trim} {value:ellipsis(10)}&lt;/span&gt;',
     '&lt;/div&gt;'
     '&lt;div name="{id}"&gt;',
         '&lt;span class="{cls}"&gt;{name:trim} {value:ellipsis(10)}&lt;/span&gt;',
     '&lt;/div&gt;'
@@ -24,19 +25,31 @@ t.append('some-element', {id: 'myid', cls: 'myclass', name: 'foo', value: 'bar'}
 </code></pre>
 * For more information see this blog post with examples: <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">DomHelper - Create Elements using DOM, HTML fragments and Templates</a>. 
 * @constructor
 </code></pre>
 * For more information see this blog post with examples: <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">DomHelper - Create Elements using DOM, HTML fragments and Templates</a>. 
 * @constructor
-* @param {String/Array} html The HTML fragment or an array of fragments to join("") or multiple arguments to join("")
+* @param {Object} cfg - Configuration object.
+* @param {String/Array} html 
 */
 */
-Roo.Template = function(html){
-    if(html instanceof Array){
-        html = html.join("");
+Roo.Template = function(cfg){
+    if(cfg instanceof Array){
+        cfg = cfg.join("");
     }else if(arguments.length > 1){
     }else if(arguments.length > 1){
-        html = Array.prototype.join.call(arguments, "");
+        cfg = Array.prototype.join.call(arguments, "");
     }
     }
+    
     /**@private*/
     /**@private*/
-    this.html = html;
+    if (typeof(cfg) == 'object') {
+        Roo.apply(this,cfg)
+    } else {
+        this.html = cfg;
+    }
+    
     
 };
 Roo.Template.prototype = {
     
 };
 Roo.Template.prototype = {
+    
+    /**
+     * @cfg {String} html  The HTML fragment or an array of fragments to join("") or multiple arguments to join("")
+     */
+    html : '',
     /**
      * Returns an HTML fragment of this template with the specified values applied.
      * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
     /**
      * Returns an HTML fragment of this template with the specified values applied.
      * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})