Template repeat if syntax?

119 views
Skip to first unread message

Arthur Evans

unread,
Mar 22, 2014, 3:00:39 PM3/22/14
to polym...@googlegroups.com
Hi folks,

I'm curious about the use of template binding with the `repeat if` syntax. This is documented in the template binding library:

<template repeat if="{{ conditionalValue }}">
  Repeat if and only if conditionalValue is truthy.
</template>

However, things work a bit differently inside a Polymer element, and I haven't been able to get this form to work. Does anyone know if `repeat if` works inside a Polymer element?

Thanks,
Arthur

Scott Miles

unread,
Mar 22, 2014, 3:04:31 PM3/22/14
to Arthur Evans, polymer-dev
>> However, things work a bit differently inside a Polymer element

Can you spell this out? What have you tried?




Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CADSbU_x4PoEL4bN9VjnvztPG3phASZ6GSG%3D%3Dsg7DBXRzzEWjpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Arthur Evans

unread,
Mar 22, 2014, 3:52:01 PM3/22/14
to Scott Miles, polymer-dev
My apologies, apparently I just didn't try enough things... or RTFM. This works as expected:

        <ul>
          <template repeat="{{s in salutations}}"  if="{{ salutations.length }}">
            <li>{{s.what}}: <input type="text" value="{{s.who}}"></li>
          </template>
        </ul>

I tried  if="{{ true }}" at first. Then I checked the expressions doc and realized that "true/false" weren't listed as accepted literals. 

However, I also found that  if="{{ 1 }}" didn't evaluate as truthy, but if="{{ 1 == 1 }}" did. That seems like a hiccup in the expression library (but it might be just another gap in my understanding).

Having a separate variable, this.showSaluations and using if="{{showSalutations}}" also worked as expected. 

My other confusions apparently related to my not getting the scoping correct. Fixed that.

Thanks,
Arthur

Erik Arvidsson

unread,
Mar 24, 2014, 10:40:04 AM3/24/14
to Arthur Evans, Scott Miles, polymer-dev
Polymer Expressions supports true and false as well as numbers and strings.


So if `if="{{true}}"` is not working that is a bug.



For more options, visit https://groups.google.com/d/optout.



--
erik


Reply all
Reply to author
Forward
0 new messages