From: Alan Knowles Date: Wed, 28 Jul 2010 04:54:47 +0000 (+0800) Subject: Roo/Template.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=53776470795f203688081b8ae981e3cb14a2a9ce Roo/Template.js --- diff --git a/Roo/Template.js b/Roo/Template.js index 597f93ad49..3b9d6a38cb 100644 --- a/Roo/Template.js +++ b/Roo/Template.js @@ -15,7 +15,8 @@ * For a list of available format functions, see {@link Roo.util.Format}.
* Usage:

-var t = new Roo.Template(
+var t = new Roo.Template({
+    * html : 
     '<div name="{id}">',
         '<span class="{cls}">{name:trim} {value:ellipsis(10)}</span>',
     '</div>'
@@ -24,19 +25,31 @@ t.append('some-element', {id: 'myid', cls: 'myclass', name: 'foo', value: 'bar'}
 
* For more information see this blog post with examples: DomHelper - Create Elements using DOM, HTML fragments and Templates. * @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){ - html = Array.prototype.join.call(arguments, ""); + cfg = Array.prototype.join.call(arguments, ""); } + /**@private*/ - this.html = html; + if (typeof(cfg) == 'object') { + Roo.apply(this,cfg) + } else { + this.html = cfg; + } + }; 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'})