Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Allow maintaining templates inside an element without Polymer stripping the content #185

Open
MaKleSoft opened this issue Aug 28, 2014 · 4 comments

Comments

@MaKleSoft
Copy link

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.

@sorvell
Copy link
Contributor

sorvell commented Aug 29, 2014

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.

@sorvell sorvell removed the p1 label Aug 29, 2014
@MaKleSoft
Copy link
Author

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.

@jmesserly
Copy link
Contributor

Nice example, Martin. Illustrates the problem nicely.
Would something like this work: http://jsbin.com/nimohiralega/4/edit

@jmesserly
Copy link
Contributor

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.

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

No branches or pull requests

3 participants