googlearchive / TemplateBinding

TemplateBinding Prolyfill
290 stars 61 forks source link

repeat="{{ thing in things }}" form does not work #198

Closed benogle closed 9 years ago

benogle commented 9 years ago

Using 0.4.2, the thing in things form of repeat does not work for me:

model = 
  things: [
    {name: 'one'}
    {name: 'two'}
    {name: 'three'}
    {name: 'four'}
  ]
<template bind="{{}}">
  <div>
    <template repeat="{{ thing in things }}">
      <span class="name">{{ thing.name }}</span>,
    </template>
  </div>
</template>

This works fine:

<template bind="{{}}">
  <div>
    <template repeat="{{ things }}">
      <span class="name">{{ name }}</span>,
    </template>
  </div>
</template>

Seems that there are no tests for this form either. Is this a bug or was this feature removed intentionally?

jmesserly commented 9 years ago

this feature is supported by https://github.com/Polymer/polymer-expressions

I don't recall it being supported by raw TemplateBinding. What might have happened is this functionality (polymer-expressions) used to be included in platform.js, but it's now in polymer.js ... at least, that's my guess.

benogle commented 9 years ago

Ah ok. It's in the docs here for TemplateBinding: https://www.polymer-project.org/docs/polymer/template.html

jmesserly commented 9 years ago

ah, good catch! I found this bug, I'll add a note: https://github.com/Polymer/docs/issues/635

jmesserly commented 9 years ago

btw, it should be pretty easy to pass a "binding delegate" ... it can be set as .bindingDelegate on the <template> element which then enables the various features, something like:

var t = // ... get <template> somehow
t.bindingDelegate = new PolymerExpressions();
t.model = // the model

(it's also an argument to template.createInstance, if you're using that API instead)

benogle commented 9 years ago

Thanks, I plan on playing around with the expressions. We will likely use those as well.