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
reduces apply
time
when no formatting is required.Applies the supplied values
to the template and appends
the new node(s) to the specified el
.
For example usage see the constructor.
The context element
The template values. Can be an array if the params are numeric (i.e. {0}
)
or an object (i.e. {foo: 'bar'}
).
(optional) true to return an Ext.core.Element (defaults to undefined)
The new node or Element
Alias 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.
The template values. Can be an array if the params are numeric (i.e. {0}
)
or an object (i.e. {foo: 'bar'}
).
The HTML fragment
Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML.
Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML.
A DOM element or its id
A configuration object
The created template
Applies 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.
The context element
The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
(optional) true to return a Ext.core.Element (defaults to undefined)
The new node or Element
Applies 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.
The context element
The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
(optional) true to return a Ext.core.Element (defaults to undefined)
The new node or Element
Applies 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.
The context element
The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
(optional) true to return a Ext.core.Element (defaults to undefined)
The new node or Element
Applies 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).
The context element
The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
(optional) true to return a Ext.core.Element (defaults to undefined)
The new node or Element