I would like to be able to render a remote collection fetched with <core-ajax>
as such:
<rendered-collection url="/api/items">
<custom-element value="{{ _it_ }}"></custom-element>
</rendered-collection>
where <rendered-collection>
would look something like:
<link rel="import" href="/core-ajax/core-ajax.html">
<polymer-element name="rendered-collection" attributes="url" noscript>
<template>
<core-ajax url="{{ url }}" response="{{ collection }}" auto handleAs="json"></core-ajax>
<template repeat="{{ _it_ in collection }}">
<content><!-- cannot be used like that unfortunately --></content>
</template>
</template>
</polymer-element>
I realise that this is not how <content>
is supposed to work and that I still have to inject the model into it anyway.
I have seen answers advising to retrieve the content's nodes in JS:
<style>
::content > * {
display: none;
}
</style>
<content id="content"></content>
...
<script>
Polymer('rendered-collection', {
attached: function () {
this.contentNodes = this.$.content.getDistributedNodes();
// then...how do I inject models from the collection into the nodes?
}
});
</script>
What's the best way to go?