Skip to content

Allow hooking into the template instantiation process #156

Description

@jonrimmer

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.

Activity

  1. sjmiles commented on May 22, 2013

    @sjmiles
    Contributor

    Thanks Jon.

  2. blittle commented on Jun 3, 2013

    @blittle

    👍

  3. sjmiles commented on Jul 24, 2013

    @sjmiles
    Contributor

    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

  4. sorvell commented on Oct 2, 2013

    @sorvell
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions