Results 1 to 3 of 3

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

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

    Default 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,790
    Answers
    583
    Vote Rating
    391
      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
      0  

    Default

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •