Storing Templates in Markup
- Templates can be removed from your code and placed in markup
- Provides flexibility to divide workload
- Allows you to work with an HTML editor
// static method
var tpl = Ext.XTemplate.from('tplGroceries');
tpl.compile();
var shoppingList = {
title: 'Shopping List',
foods: [
{quantity: '5', name: 'Apples', desc: 'Red and juicy'},
{quantity: '1', name: 'Bread', desc: 'Whole wheat'},
{quantity: '2', name: 'Cookies', desc: 'Chocolate chip'}
]
};
tpl.append('shoppingList', shoppingList);