1. #1
    Sencha User JamieMason's Avatar
    Join Date
    Apr 2010
    Location
    Leeds, UK
    Posts
    42
    Vote Rating
    0
    JamieMason is on a distinguished road

      0  

    Default Answered: Can you use || in Ext.XTemplate <tpl if="">

    Answered: Can you use || in Ext.XTemplate <tpl if="">


    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?

    Code:
    <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>

  2. From a quick test in Firebug it would appear you can:

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

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,625
    Vote Rating
    331
    Answers
    550
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    From a quick test in Firebug it would appear you can:

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

  4. #3
    Sencha User JamieMason's Avatar
    Join Date
    Apr 2010
    Location
    Leeds, UK
    Posts
    42
    Vote Rating
    0
    JamieMason is on a distinguished road

      0  

    Default


    Thanks!

Thread Participants: 1