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

Allow hooking into the template instantiation process #156

Closed
jonrimmer opened this issue May 22, 2013 · 4 comments
Closed

Allow hooking into the template instantiation process #156

jonrimmer opened this issue May 22, 2013 · 4 comments

Comments

@jonrimmer
Copy link

At present, Polymer looks for the first template defined in an element and instantiates it automatically within a shadow root. It would be useful to be able to override this behaviour if, for example, I wanted to include several templates and choose which of them to use based on particular conditions, such as the attributes values.

@sjmiles
Copy link
Contributor

sjmiles commented May 22, 2013

Thanks Jon.

@blittle
Copy link

blittle commented Jun 3, 2013

👍

@sjmiles
Copy link
Contributor

sjmiles commented Jul 24, 2013

This is now supported via overriding fetchTemplate method on a polymer-element:

    fetchTemplate: function(elementElement) {
      return elementElement.querySelector('template'); 
    }

There are a few other methods you can override to customize set up behavior, like parseElements. Usage is likely non-obvious, but remains To Be Documented. Here is a link to the relevant code in the meantime: https://github.com/Polymer/polymer/blob/stable/src/instance/base.js#L39

@sorvell
Copy link
Contributor

sorvell commented Oct 2, 2013

Since the functionality is there but remains to be documented, closing in favor of #305.

@sorvell sorvell closed this as completed Oct 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants