Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeating a template from "content" does not work with repeat="d in data" #396

Closed
FunkMonkey opened this issue Jan 16, 2014 · 2 comments
Closed

Comments

@FunkMonkey
Copy link

I am trying to repeat a template that is in the content of a polymer element within the shadow dom, just like it is achieved in polymer-list.

This works for repeat="{{data}}", but not for repeat="{{ d in data }}.

Here is a shortened version of polymer-list, that shows the problem:

<polymer-element name="x-repeat">
    <template>
        <div>
            <shadow></shadow>
        </div>
    </template>
    <script>Polymer('x-repeat', {
        data: ["foo", "bar"],
        enteredView: function() {
            this.template = this.querySelector('template');
          },

         templateChanged: function() {
            this.template.setAttribute('repeat', '{{ data }}'); // works
            // this.template.setAttribute('repeat', '{{ d in data }}'); // does not work
            this.template.model = this;
        }
    });</script>
</polymer-element>

And used like this:

<x-repeat>
    <template>
        <div>Data</div>
    </template>
</x-repeat>

repeat="{{data}}" will correctly create two divs, whereas switching the code to repeat="{{ d in data }} creates none.

Is this a bug or expected behaviour?

@dfreedm
Copy link
Member

dfreedm commented Jan 17, 2014

The "in" syntax is provided by the polymer-expressions library, and requires you to set "bindingDelegate" on the template to use that syntax.

this.template.bindingDelegate = new PolymerExpressions();
this.template.setAttribute('repeat', '{{ d in data }}');

Here is a working JSBin version: http://jsbin.com/UVIJoha/1/edit

@dfreedm dfreedm closed this as completed Jan 17, 2014
@FunkMonkey
Copy link
Author

thank you! works like a charm! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants