Open MaKleSoft opened 10 years ago
We recommend you avoid this type of construction and instead place a template that you want to use outside of a data-binding context outside of the element's bound template. Here's one way to do it:
http://jsbin.com/toyodu/2/edit.
This way you can easily avoid having to deal with the ref
concept.
Thanks! But I can think of at least one scenario where this won't work. Let's say we want the template to be passed in from the outside:
http://jsbin.com/nimohiralega/1/edit
Now the template is inside the binding context of the parent element, and I don't see a way of avoiding that.
Nice example, Martin. Illustrates the problem nicely. Would something like this work: http://jsbin.com/nimohiralega/4/edit
Also you can pass a "model" and "bindingDelegate" if you would like to make {{ bindings }} work inside of that template.
That's the disadvantage of my suggestion, too: createInstance will process {{ bindings }} whether you want it to or not. However, that's unavoidable since it was already inside another polymer-element's template, so the {{ bindings }} already had meaning.
As a followup on #144, is there a way to tell Polymer to not strip the content of a template element? I understand that I can still access the content via the
ref_
property but the property name suggests that it is not intended to be used that way and relying on it might break my app at some point.