Class Ext.Template
Represents an HTML fragment template. Templates can be precompiled for greater performance.
For a list of available format functions, see
Ext.util.Format.
var t = new Ext.Template(
'<div name="{id}">',
'<span class="{cls}">{name:trim} {value:ellipsis(10)}</span>',
'</div>'
);
t.append('some-element', {id: 'myid', name: 'foo', value: 'bar'});
For more information see
this blog post with examples.
属性
-
方法
-
事件
公共属性
|
disableFormats : Boolean |
Template |
True to disable format functions (default to false) |
|
re : RegExp |
Template |
The regular expression used to match template variables |
公共方法
|
Template(String/Array html ) |
Template |
|
|
Template.from(String/HTMLElement el ) : void |
Template |
<static> Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML |
|
append(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and append the new node(s) to el |
|
apply() : void |
Template |
Alias for applyTemplate |
|
applyTemplate(Object values ) : String |
Template |
Returns an HTML fragment of this template with the specified values applied |
|
compile() : void |
Template |
Compiles the template into an internal function, eliminating the RegEx overhead |
|
insertAfter(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and inserts the new node(s) after el |
|
insertBefore(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and inserts the new node(s) before el |
|
insertFirst(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and inserts the new node(s) as the first child of el |
|
overwrite(String/HTMLElement/Element el , Object values , [Boolean returnElement ]) : HTMLElement |
Template |
Applies the supplied values to the template and overwrites the content of el with the new node(s) |
|
set(String html , [Boolean compile ]) : Template |
Template |
Sets the html used as the template and optionally compiles it |
公共事件
此类没有公共事件。
属性详情
disableFormats
public Boolean disableFormats
True to disable format functions (default to false)
This property is defined by Template.
re
public RegExp re
The regular expression used to match template variables
This property is defined by Template.
构造函数
Template
public function Template(String/Array html
)
方法详情
Template.from
public function Template.from(String/HTMLElement el
)
<static> Creates a template from the passed element's value (display:none textarea, preferred) or innerHTML
This method is defined by Template.
append
public function append(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and append the new node(s) to el
This method is defined by Template.
apply
public function apply()
This method is defined by Template.
applyTemplate
public function applyTemplate(Object values
)
Returns an HTML fragment of this template with the specified values applied
This method is defined by Template.
compile
public function compile()
Compiles the template into an internal function, eliminating the RegEx overhead
This method is defined by Template.
insertAfter
public function insertAfter(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and inserts the new node(s) after el
This method is defined by Template.
insertBefore
public function insertBefore(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and inserts the new node(s) before el
This method is defined by Template.
insertFirst
public function insertFirst(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and inserts the new node(s) as the first child of el
This method is defined by Template.
overwrite
public function overwrite(String/HTMLElement/Element el
, Object values
, [Boolean returnElement
])
Applies the supplied values to the template and overwrites the content of el with the new node(s)
This method is defined by Template.
set
public function set(String html
, [Boolean compile
])
Sets the html used as the template and optionally compiles it
参数:
html
: Stringcompile
: Boolean(可选)
返回:
This method is defined by Template.