PDA

View Full Version : Ext.Template



Stju
16 Sep 2009, 11:52 AM
Hi!
Banging again my head .. There are almost zero samples on how to implement logic in templates...
Can't get proper formating.. Code shown is partially shortened..


tpl : new Ext.Template(
'<h1>Transport</h1>',
'<tpl if="is_gps==1">YES</tpl>',
'<tpl if="is_gps==0">NO</tpl>'
)
Depending on is_gps value result should be either YES on NO , bet I am getting YESNO...
What I am doing wrong??
Stju

Animal
16 Sep 2009, 11:53 AM
There are no examples because it's not possible.

XTemplate on the other hand is pretty well documented.

Stju
16 Sep 2009, 12:01 PM
Hmmm,
Excerpt from Examples(First example in Templates section):


var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Company: {company}</p>',
'<p>Location: {city}, {state}</p>',
'<p>Kids: ',
'<tpl for="kids" if="name==\'Jack Slocum\'">',
'<tpl if="age &gt; 1"><p>{#}. {parent.name}\'s kid - {name}</p></tpl>',
'</tpl></p>'
);



What then is meant to be here : <tpl if="age &gt; 1"> ?
In my opinion it's IF AGE>1 then show the remaining part of that template..
Correct me if I am wrong.
Stju

Animal
16 Sep 2009, 9:46 PM
Correct, there's an example for you.