Package: | Ext |
Defined In: | Template.js |
Class: | Template |
Subclasses: | XTemplate |
Extends: | Object |
Represents an HTML fragment template. Templates may be precompiled for greater performance.
An instance of this class may be created by passing to the constructor either a single argument, or multiple arguments:var t = new Ext.Template("<div>Hello {0}.</div>");
t.append('some-element', ['foo']);
join('')
.
var t = new Ext.Template([
'<div name="{id}">',
'<span class="{cls}">{name:trim} {value:ellipsis(10)}</span>',
'</div>',
]);
t.compile();
t.append('some-element', {id: 'myid', cls: 'myclass', name: 'foo', value: 'bar'});
join('')
.
var t = new Ext.Template(
'<div name="{id}">',
'<span class="{cls}">{name} {value}</span>',
'</div>',
// a configuration object:
{
compiled: true, // compile immediately
}
);
Notes:
disableFormats
are not applicable for Sencha Touch.disableFormats
reduces apply
time
when no formatting is required.Config Options | Defined By | |
---|---|---|
disableFormats : Boolean true to disable format functions in the template. If the template doesn't contain format functions, setting
disableF... true to disable format functions in the template. If the template doesn't contain format functions, setting
disableFormats to true will reduce apply time (defaults to false) | Template |
Method | Defined By | |
---|---|---|
Template.from( String/HTMLElement el , Object config )
:
Ext.Template<static> Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML. <static> Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML. Parameters:
| Template | |
append( Mixed el , Object/Array values , [Boolean returnElement ] )
:
HTMLElement/Ext.ElementApplies the supplied values to the template and appends
the new node(s) to the specified el.
For example usage see th... Applies the supplied values to the template and appends
the new node(s) to the specified el .
For example usage see the constructor. Parameters:
| Template | |
apply( Object/Array values )
:
StringAlias for applyTemplate
Returns an HTML fragment of this template with the specified values applied. Alias for applyTemplate
Returns an HTML fragment of this template with the specified values applied.Parameters:
| Template | |
insertAfter( Mixed el , Object/Array values , [Boolean returnElement ] )
:
HTMLElement/Ext.ElementApplies the supplied values to the template and inserts the new node(s) after el. Applies the supplied values to the template and inserts the new node(s) after el. Parameters:
| Template | |
insertBefore( Mixed el , Object/Array values , [Boolean returnElement ] )
:
HTMLElement/Ext.ElementApplies the supplied values to the template and inserts the new node(s) before el. Applies the supplied values to the template and inserts the new node(s) before el. Parameters:
| Template | |
insertFirst( Mixed el , Object/Array values , [Boolean returnElement ] )
:
HTMLElement/Ext.ElementApplies the supplied values to the template and inserts the new node(s) as the first child of el. Applies the supplied values to the template and inserts the new node(s) as the first child of el. Parameters:
| Template | |
overwrite( Mixed el , Object/Array values , [Boolean returnElement ] )
:
HTMLElement/Ext.ElementApplies the supplied values to the template and overwrites the content of el with the new node(s). Applies the supplied values to the template and overwrites the content of el with the new node(s). Parameters:
| Template | |
set( String html , [Boolean compile ] )
:
Ext.TemplateSets the HTML used as the template and optionally compiles it. Sets the HTML used as the template and optionally compiles it. Parameters:
| Template |