[quote]
[/quote]
var menuEditTemplate = new Ext.Template(
'<a href="#"><img border="0" src="{imgsrc}"></a>'
);
menuEditTemplate.compile();
var result = menuEditTemplate.apply(
{imgsrc:'resources/images/icon/16/application_form_edit.png'}
);
var dh=Ext.DomHelper;
// create the node
var list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});
// get template
var tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});
for(var i = 0; i < 5, i++){
tpl.append(list, [i]);
// use template to append to the actual node
}
<div id="blog-roll"></div>
<script type="text/javascript">
//例子一:
<!--
var html = '<a id="{id}" href="{url}" class="nav">{text}</a>';
var tpl = new Ext.DomHelper.createTemplate(html);
tpl.append('blog-roll',{
id: 'link1',
url: 'http://z-jianwen.iteye.com/admin/blogs/765729',
text: "Jack's Site"}
);
tpl.append('blog-roll', {
id: 'link2',
url: 'http://www.dustindiaz.com/',
text: "Dustin's Site"}
);
-->
[/quote]