1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <meta http-equiv="content-type" content="text/html; charset=undefined" />
8 <meta name="generator" content="JsDoc Toolkit" />
11 <title>JsDoc Reference - Roo.Template</title>
14 <link rel="stylesheet" type="text/css" href="../../css/roojs.css" />
15 <link rel="stylesheet" type="text/css" href="../default.css" />
18 <script type="text/javascript" src="../page.js">
25 <body onload="RooDocsPage.onload();">
28 <div class="body-wrap">
30 <!-- ============================== links to methods. ================================= -->
32 <div class="top-tools">
34 <a class="inner-link" href="#Roo.Template-props"><img src="resources/s.gif" class="item-icon icon-prop">Properties</a>
35 <a class="inner-link" href="#Roo.Template-methods"><img src="resources/s.gif" class="item-icon icon-method">Methods</a>
36 <a class="inner-link" href="#Roo.Template-events"><img src="resources/s.gif" class="item-icon icon-event">Events</a>
37 <a class="inner-link" href="#Roo.Template-configs"><img src="resources/s.gif" class="item-icon icon-config">Config Options</a>
38 <a class="bookmark" href="NEED_TO_CREATE_DIRECT_LINK_HREF"><img src="resources/s.gif" class="item-icon icon-fav">Direct Link</a>
43 <!-- ============================== inheritance Block. ================================= -->
45 <!-- ============================== class title / details ============================ -->
48 <h1 class="classTitle">
53 <table cellspacing="0" class="class-summary-table">
55 <tr><td class="label">Package:</td><td class="hd-info">Roo</td></tr>
57 <tr><td class="label">Defined In:</td><td class="hd-info">
59 <a href="./src/Roo_Template.js.html">Roo/Template.js</a>.
62 <tr><td class="label">Class:</td><td class="hd-info">Template</td></tr>
65 <tr><td class="label">Subclasses:</td><td class="hd-info">
66 <a href="./Roo.DomTemplate.html#constructor" roo:cls="Roo.DomTemplate.html#constructor">Roo.DomTemplate</a>, <a href="./Roo.MasterTemplate.html#constructor" roo:cls="Roo.MasterTemplate.html#constructor">Roo.MasterTemplate</a>, <a href="./Roo.XTemplate.html#constructor" roo:cls="Roo.XTemplate.html#constructor">Roo.XTemplate</a>
77 <!-- ============================== class summary ========================== -->
78 <div class="description">
79 Represents an HTML fragment template. Templates can be precompiled for greater performance.<br/>For a list of available format functions, see {<b>link</b> Roo.util.Format}.<br /><br/>Usage:<br/><pre><code><br/>var t = new Roo.Template({<br/> html : '<div name="{id}">' + <br/> '<span class="{cls}">{name:trim} {someval:this.myformat}{value:ellipsis(10)}</span>' +<br/> '</div>',<br/> myformat: function (value, allValues) {<br/> return 'XX' + value;<br/> }<br/>});<br/>t.append('some-element', {id: 'myid', cls: 'myclass', name: 'foo', value: 'bar'});<br/></code></pre><br/>For more information see this blog post with examples:<br/> <a href="http://www.cnitblog.com/seeyeah/archive/2011/12/30/38728.html/">DomHelper<br/> - Create Elements using DOM, HTML fragments and Templates</a>.
83 <!-- ============================== Class comment block... ========================== -->
85 <div class="comments">
86 <b>Class Comments / Notes</B> =>
87 <u onclick="parent.CommentDialog.showCommentId = 'Roo.Template';">[Add Your comment/notes about this class]</u>
89 <iframe frameborder="0" id="comments-Roo" style="border: none;width:100%;"
90 src="/blog.php/GtkDjsComments/Roo.Template.html"></iframe>
95 <!-- ============================== config options ========================== -->
100 <div class="hr"></div>
101 <a id="Roo.Template-configs"></a>
107 <table cellspacing="0" class="member-table">
108 <caption>Config Options (Usually are also Properties)</caption>
112 <th class="sig-header" colspan="2">Options</th>
114 <th class="msource-header">Defined By</th>
121 <tr class="config-row expandable config-row-alt0 notInherited">
122 <td class="micon"><a class="exi" href="#expand"> </a></td>
125 <a id="Roo.Template-cfg-html" name=".html"></a>
126 <div class="fixedFont">
127 <b class="itemname">html</b> : <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
133 <div class="short">The HTML fragment or an array of fragments to join("") or multiple arguments to join("")</div>
137 <div class="long">The HTML fragment or an array of fragments to join("") or multiple arguments to join("")</div>
151 <tr class="config-row expandable config-row-alt1 notInherited">
152 <td class="micon"><a class="exi" href="#expand"> </a></td>
155 <a id="Roo.Template-cfg-url" name=".url"></a>
156 <div class="fixedFont">
157 <b class="itemname">url</b> : <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
163 <div class="short">The Url to load the template from.</div>
167 <div class="long">The Url to load the template from. beware if you are loading from a url, the data may not be ready if you use it instantly..<br/> it should be fixed so that template is observable...</div>
191 <!-- ============================== public properties ==================== -->
195 <a id="Roo.Template-props"></a>
201 <table cellspacing="0" class="member-table">
202 <caption class="Empty">Public Properties - Has None</caption>
208 <!-- ============================== methods summary / details ======================== -->
211 <a id="Roo.Template-methods"></a>
212 <!-- constructor?? -->
219 <!-- then dynamics first -->
226 <table cellspacing="0" class="member-table">
227 <caption>Public Methods</caption>
229 <th class="sig-header" colspan="2">Method</th>
230 <th class="msource-header">Defined By</th>
240 <tr class="method-row config-row-alt0 expandable notInherited">
241 <td class="micon"><a class="exi" href="#expand"> </a></td>
245 <a id="Roo-method-Template" name=".Template"></a>
246 <div class="fixedFont">
247 <span class="attributes">new <B>Roo.</B></span><b class="itemname">Template</b>
249 (<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>cfg</i></B>)
257 <div class="short">Create a new Roo.Template</div>
264 Create a new Roo.Template
267 <dl class="detailList">
268 <dt class="heading">Parameters:</dt>
271 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>cfg</b>
274 <dd>- Configuration object.</dd>
298 <tr class="method-row config-row-alt1 expandable notInherited">
299 <td class="micon"><a class="exi" href="#expand"> </a></td>
303 <a id="Roo.Template-method-from" name=".from"></a>
304 <div class="fixedFont">
305 <span class="attributes">Roo.Template.</span><b class="itemname">from</b>
307 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement <B><i>el</i></B>)
314 <div class="short">Creates a template from the passed element's value (<i>display:none</i> textarea, preferred) or innerHTML.</div>
320 Creates a template from the passed element's value (<i>display:none</i> textarea, preferred) or innerHTML.
327 <dl class="detailList">
328 <dt class="heading">Parameters:</dt>
331 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement</span> <b>el</b>
334 <dd>A DOM element or its id</dd>
360 <tr class="method-row config-row-alt0 expandable notInherited">
361 <td class="micon"><a class="exi" href="#expand"> </a></td>
365 <a id="Roo.Template-method-append" name=".append"></a>
366 <div class="fixedFont">
367 <span class="attributes"></span><b class="itemname">append</b>
369 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
375 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
384 <div class="short">Applies the supplied values to the template and appends the new node(s) to el.</div>
390 Applies the supplied values to the template and appends the new node(s) to el.
397 <dl class="detailList">
398 <dt class="heading">Parameters:</dt>
401 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
404 <dd>The context element</dd>
407 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
410 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
413 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
416 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
424 <dl class="detailList">
425 <dt class="heading">Returns:</dt>
427 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
449 <tr class="method-row config-row-alt1 expandable notInherited">
450 <td class="micon"><a class="exi" href="#expand"> </a></td>
454 <a id="Roo.Template-method-apply" name=".apply"></a>
455 <div class="fixedFont">
456 <span class="attributes"></span><b class="itemname">apply</b>
465 <div class="short">Alias for {<b>link</b> <b>applyTemplate</b>}</div>
471 Alias for {<b>link</b> <b>applyTemplate</b>}
500 <tr class="method-row config-row-alt0 expandable notInherited">
501 <td class="micon"><a class="exi" href="#expand"> </a></td>
505 <a id="Roo.Template-method-applyTemplate" name=".applyTemplate"></a>
506 <div class="fixedFont">
507 <span class="attributes"></span><b class="itemname">applyTemplate</b>
509 (<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>)
515 <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
524 <div class="short">Returns an HTML fragment of this template with the specified values applied.</div>
530 Returns an HTML fragment of this template with the specified values applied.
537 <dl class="detailList">
538 <dt class="heading">Parameters:</dt>
541 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
544 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
552 <dl class="detailList">
553 <dt class="heading">Returns:</dt>
555 <dd><span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> The HTML fragment</dd>
577 <tr class="method-row config-row-alt1 expandable notInherited">
578 <td class="micon"><a class="exi" href="#expand"> </a></td>
582 <a id="Roo.Template-method-compile" name=".compile"></a>
583 <div class="fixedFont">
584 <span class="attributes"></span><b class="itemname">compile</b>
592 <a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a>
601 <div class="short">Compiles the template into an internal function, eliminating the RegEx overhead.</div>
607 Compiles the template into an internal function, eliminating the RegEx overhead.
618 <dl class="detailList">
619 <dt class="heading">Returns:</dt>
621 <dd><span class="fixedFont"><a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a></span> this</dd>
643 <tr class="method-row config-row-alt0 expandable notInherited">
644 <td class="micon"><a class="exi" href="#expand"> </a></td>
648 <a id="Roo.Template-method-insertAfter" name=".insertAfter"></a>
649 <div class="fixedFont">
650 <span class="attributes"></span><b class="itemname">insertAfter</b>
652 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
658 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
667 <div class="short">Applies the supplied values to the template and inserts the new node(s) after el.</div>
673 Applies the supplied values to the template and inserts the new node(s) after el.
680 <dl class="detailList">
681 <dt class="heading">Parameters:</dt>
684 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
687 <dd>The context element</dd>
690 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
693 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
696 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
699 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
707 <dl class="detailList">
708 <dt class="heading">Returns:</dt>
710 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
732 <tr class="method-row config-row-alt1 expandable notInherited">
733 <td class="micon"><a class="exi" href="#expand"> </a></td>
737 <a id="Roo.Template-method-insertBefore" name=".insertBefore"></a>
738 <div class="fixedFont">
739 <span class="attributes"></span><b class="itemname">insertBefore</b>
741 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
747 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
756 <div class="short">Applies the supplied values to the template and inserts the new node(s) before el.</div>
762 Applies the supplied values to the template and inserts the new node(s) before el.
769 <dl class="detailList">
770 <dt class="heading">Parameters:</dt>
773 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
776 <dd>The context element</dd>
779 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
782 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
785 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
788 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
796 <dl class="detailList">
797 <dt class="heading">Returns:</dt>
799 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
821 <tr class="method-row config-row-alt0 expandable notInherited">
822 <td class="micon"><a class="exi" href="#expand"> </a></td>
826 <a id="Roo.Template-method-insertFirst" name=".insertFirst"></a>
827 <div class="fixedFont">
828 <span class="attributes"></span><b class="itemname">insertFirst</b>
830 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
836 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
845 <div class="short">Applies the supplied values to the template and inserts the new node(s) as the first child of el.</div>
851 Applies the supplied values to the template and inserts the new node(s) as the first child of el.
858 <dl class="detailList">
859 <dt class="heading">Parameters:</dt>
862 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
865 <dd>The context element</dd>
868 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
871 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
874 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
877 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
885 <dl class="detailList">
886 <dt class="heading">Returns:</dt>
888 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
910 <tr class="method-row config-row-alt1 expandable notInherited">
911 <td class="micon"><a class="exi" href="#expand"> </a></td>
915 <a id="Roo.Template-method-overwrite" name=".overwrite"></a>
916 <div class="fixedFont">
917 <span class="attributes"></span><b class="itemname">overwrite</b>
919 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>values</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>returnElement</i></B>)
925 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element
934 <div class="short">Applies the supplied values to the template and overwrites the content of el with the new node(s).</div>
940 Applies the supplied values to the template and overwrites the content of el with the new node(s).
947 <dl class="detailList">
948 <dt class="heading">Parameters:</dt>
951 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
954 <dd>The context element</dd>
957 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>values</b>
960 <dd>The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</dd>
963 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>returnElement</b>
966 <dd>(optional) true to return a Roo.Element (defaults to undefined)</dd>
974 <dl class="detailList">
975 <dt class="heading">Returns:</dt>
977 <dd><span class="fixedFont"><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037">HTMLElement</a>/Roo.Element</span> The new node or Element</dd>
999 <tr class="method-row config-row-alt0 expandable notInherited">
1000 <td class="micon"><a class="exi" href="#expand"> </a></td>
1004 <a id="Roo.Template-method-set" name=".set"></a>
1005 <div class="fixedFont">
1006 <span class="attributes"></span><b class="itemname">set</b>
1008 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>html</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>compile</i></B>)
1014 <a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a>
1023 <div class="short">Sets the HTML used as the template and optionally compiles it.</div>
1029 Sets the HTML used as the template and optionally compiles it.
1036 <dl class="detailList">
1037 <dt class="heading">Parameters:</dt>
1040 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>html</b>
1046 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>compile</b>
1049 <dd>(optional) True to compile the template (defaults to undefined)</dd>
1057 <dl class="detailList">
1058 <dt class="heading">Returns:</dt>
1060 <dd><span class="fixedFont"><a href="./Roo.Template.html#constructor" roo:cls="Roo.Template.html#constructor">Roo.Template</a></span> this</dd>
1074 <td class="msource">
1085 <!-- ============================== events summary / details ======================== -->
1088 <a id="Roo.Template-events"></a>
1094 <table cellspacing="0" class="member-table">
1095 <caption class="Empty">Events - Has None</caption>
1106 <!-- ============================== footer ================================= -->
1107 <div class="fineprint" style="clear:both">
1109 Documentation generated by <a href="http://www.akbkhome.com" target="_blankt">Introspection Doc Generator</a> on Thu Apr 24 2014 16:54:31 GMT+0800 (HKT)
1111 <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a>