Closed binoculars closed 10 years ago
Fails:
<ul>
<template repeat="{{str in arrayOfStrings}}">
<li>{{str}}</li>
</template>
</ul>
Works:
<ul>
<template repeat="{{arrayOfStrings}}">
<li>{{}}</li>
</template>
</ul>
Isn't this just because the foo in foos
syntax is part of polymer-expressions, not vanilla TemplateBinding? http://jsbin.com/qolisemi/1/edit (wrapping the whole thing in an element) works fine.
Doh!
Sorry, I completely messed this up.
@binoculars, your example is not parallel. In the first case, you are binding to an object and then plucking out a value from inside. The parallel constructions are:
<template repeat="{{ arrayOfObjects }}">
<li>{{ value }}</li>
</template>
<template repeat="{{ arrayOfStrings }}">
<li>{{}}</li>
</template>
<template repeat="{{ arrayOfIntegers }}">
<li>{{}}</li>
</template>
In all cases, {{}}
represents the object bound to the iteration.
As @ajklein correctly points out, the aliasing syntax is an extra provided by the polymer-expressions library.
You're absolutely correct. I wasn't aware of {{}}
. I think you can see where the confusion is happening though--maybe something to improve on? Not sure if it would be possible or in keeping with best practices of some features in Polymer Expressions were available by default TemplateBinding.
Yes, we see where the confusion is happening.
TemplateBinding being separated from additional expression logic is a good design, however it would clearly be useful to have some kind of bundle with polymer-expressions, especially since the latter does not have any actual dependencies on Polymer. You should be able to load both libs without too much trouble.
Fwiw, we are focused on Polymer as a package including the data-binding system, and although we have structured things such that it's possible to use the pieces individually, as a survival mechanism we aren't providing much help with doing that. We'll see how things evolve.
Thanks for the ticket!
I'd like the iteration in template repeat to be more intuitive.
Take for instance,
This seems to work just fine:
However, the following do not work:
This will print test twice.