4560e0cbe092f1daefd893995836e0dc8ba5a271.svn-base 17 KB

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