Ext.Template.html
17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<div class="body-wrap">
<div class="top-tools">
<a class="inner-link" href="#Ext.Template-props"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-prop">Properties</a>
<a class="inner-link" href="#Ext.Template-methods"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-method">Methods</a>
<a class="inner-link" href="#Ext.Template-events"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-event">Events</a>
<a class="bookmark" href="../docs/?class=Ext.Template"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-fav">Direct Link</a>
</div>
<h1>Class Ext.Template</h1>
<table cellspacing="0">
<tr><td class="label">Package:</td><td class="hd-info">Ext</td></tr>
<tr><td class="label">Defined In:</td><td class="hd-info"><a href="../source/core/Template_wev8.js" target="_blank">Template_wev8.js</a></td></tr>
<tr><td class="label">Class:</td><td class="hd-info">Template</td></tr>
<tr><td class="label">Subclasses:</td><td class="hd-info"><a ext:cls="Ext.XTemplate" href="output/Ext.XTemplate.html">XTemplate</a></td></tr>
<tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
</table>
<div class="description">
Represents an HTML fragment template. Templates can be precompiled for greater performance.
For a list of available format functions, see <a ext:cls="Ext.util.Format" href="output/Ext.util.Format.html">Ext.util.Format</a>.<br />
Usage:
<pre><code>var t = <b>new</b> Ext.Template(
<em>'<div name="{id}">'</em>,
<em>'<span class="{cls}">{name:trim} {value:ellipsis(10)}</span>'</em>,
<em>'</div>'</em>
);
t.append(<em>'some-element'</em>, {id: <em>'myid'</em>, cls: <em>'myclass'</em>, name: <em>'foo'</em>, value: <em>'bar'</em>});</code></pre>
For more information see this blog post with examples: <a href="http://www.jackslocum.com/blog/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">DomHelper - Create Elements using DOM, HTML fragments and Templates</a>. </div>
<div class="hr"></div>
<a id="Ext.Template-props"></a>
<h2>Public Properties</h2>
<table cellspacing="0" class="member-table">
<tr>
<th class="sig-header" colspan="2">Property</th>
<th class="msource-header">Defined By</th>
</tr>
<tr class="property-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-disableFormats"></a>
<b>disableFormats</b> : Boolean <div class="mdesc">
True to disable format functions (defaults to false) </div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="property-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-re"></a>
<b>re</b> : RegExp <div class="mdesc">
The regular expression used to match template variables </div>
</td>
<td class="msource">Template</td>
</tr>
</table>
<a id="Ext.Template-methods"></a>
<h2>Public Methods</h2>
<table cellspacing="0" class="member-table">
<tr>
<th class="sig-header" colspan="2">Method</th>
<th class="msource-header">Defined By</th>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-Template"></a>
<b>Template</b>( <code>String/Array html</code> ) <div class="mdesc">
<div class="short"></div>
<div class="long">
<div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>html</code> : String/Array<div class="sub-desc">The HTML fragment or an array of fragments to join("") or multiple arguments to join("")</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code></code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-Template.from"></a>
<b>Template.from</b>( <code>String/HTMLElement el</code>, <code>Object config</code> ) : Ext.Template <div class="mdesc">
<div class="short"><static> Creates a template from the passed element's value (<i>display:none</i> textarea, preferred) or innerHTML.</div>
<div class="long">
<static> Creates a template from the passed element's value (<i>display:none</i> textarea, preferred) or innerHTML. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : String/HTMLElement<div class="sub-desc">A DOM element or its id</div></li><li><code>config</code> : Object<div class="sub-desc">A configuration object</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Ext.Template</code><div class="sub-desc">The created template</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-append"></a>
<b>append</b>( <code>Mixed el</code>, <code>Object/Array values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
<div class="short">Applies the supplied values to the template and appends the new node(s) to el.</div>
<div class="long">
Applies the supplied values to the template and appends the new node(s) to el. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>values</code> : Object/Array<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element (defaults to undefined)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node or Element</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-apply"></a>
<b>apply</b>() : void <div class="mdesc">
<div class="short">Alias for <a ext:cls="Ext.Template" ext:member="applyTemplate" href="output/Ext.Template.html#applyTemplate">applyTemplate</a></div>
<div class="long">
Alias for <a ext:cls="Ext.Template" ext:member="applyTemplate" href="output/Ext.Template.html#applyTemplate">applyTemplate</a> <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-applyTemplate"></a>
<b>applyTemplate</b>( <code>Object/Array values</code> ) : String <div class="mdesc">
<div class="short">Returns an HTML fragment of this template with the specified values applied.</div>
<div class="long">
Returns an HTML fragment of this template with the specified values applied. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>values</code> : Object/Array<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>String</code><div class="sub-desc">The HTML fragment</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-compile"></a>
<b>compile</b>() : Ext.Template <div class="mdesc">
<div class="short">Compiles the template into an internal function, eliminating the RegEx overhead.</div>
<div class="long">
Compiles the template into an internal function, eliminating the RegEx overhead. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Ext.Template</code><div class="sub-desc">this</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-insertAfter"></a>
<b>insertAfter</b>( <code>Mixed el</code>, <code>Object/Array values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
<div class="short">Applies the supplied values to the template and inserts the new node(s) after el.</div>
<div class="long">
Applies the supplied values to the template and inserts the new node(s) after el. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>values</code> : Object/Array<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element (defaults to undefined)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node or Element</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-insertBefore"></a>
<b>insertBefore</b>( <code>Mixed el</code>, <code>Object/Array values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
<div class="short">Applies the supplied values to the template and inserts the new node(s) before el.</div>
<div class="long">
Applies the supplied values to the template and inserts the new node(s) before el. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>values</code> : Object/Array<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element (defaults to undefined)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node or Element</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-insertFirst"></a>
<b>insertFirst</b>( <code>Mixed el</code>, <code>Object/Array values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
<div class="short">Applies the supplied values to the template and inserts the new node(s) as the first child of el.</div>
<div class="long">
Applies the supplied values to the template and inserts the new node(s) as the first child of el. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>values</code> : Object/Array<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element (defaults to undefined)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node or Element</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-overwrite"></a>
<b>overwrite</b>( <code>Mixed el</code>, <code>Object/Array values</code>, <span class="optional" title="Optional">[<code>Boolean returnElement</code>]</span> ) : HTMLElement/Ext.Element <div class="mdesc">
<div class="short">Applies the supplied values to the template and overwrites the content of el with the new node(s).</div>
<div class="long">
Applies the supplied values to the template and overwrites the content of el with the new node(s). <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>el</code> : Mixed<div class="sub-desc">The context element</div></li><li><code>values</code> : Object/Array<div class="sub-desc">The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})</div></li><li><code>returnElement</code> : Boolean<div class="sub-desc">(optional) true to return a Ext.Element (defaults to undefined)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>HTMLElement/Ext.Element</code><div class="sub-desc">The new node or Element</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.Template-set"></a>
<b>set</b>( <code>String html</code>, <span class="optional" title="Optional">[<code>Boolean compile</code>]</span> ) : Ext.Template <div class="mdesc">
<div class="short">Sets the HTML used as the template and optionally compiles it.</div>
<div class="long">
Sets the HTML used as the template and optionally compiles it. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>html</code> : String<div class="sub-desc"></div></li><li><code>compile</code> : Boolean<div class="sub-desc">(optional) True to compile the template (defaults to undefined)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Ext.Template</code><div class="sub-desc">this</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Template</td>
</tr>
</table>
<a id="Ext.Template-events"></a>
<h2>Public Events</h2>
<div class="no-members">This class has no public events.</div>
</div>