PDA

View Full Version : Can you use || in Ext.XTemplate <tpl if="">



JamieMason
25 Oct 2011, 8:58 AM
Ultra quick question, there's no mention of || in the docs at http://docs.sencha.com/ext-js/4-0/#!/api/Ext.XTemplate, can you use || as well?


<tpl if="age > 1 && age < 10">Child</tpl><tpl if="age >= 10 && age < 18">Teenager</tpl>
<tpl if="this.isGirl(name)">...</tpl>
<tpl if="id==\'download\'">...</tpl>
<tpl if="needsIcon"><img src="{icon}" class="{iconCls}"/></tpl>
// no good:
<tpl if="name == "Tommy"">Hello</tpl>
// encode " if it is part of the condition, e.g.
<tpl if="name == &quot;Tommy&quot;">Hello</tpl>

skirtle
25 Oct 2011, 1:16 PM
From a quick test in Firebug it would appear you can:


new Ext.XTemplate('<tpl if="age === 6 || age === 5">Yes</tpl>').apply({age: 5});

JamieMason
12 Dec 2011, 1:39 AM
Thanks!