ProgressiveMonkey
ProgressiveMonkey

Reputation: 315

Pass DOM nodes to Polymer as attributes

Ok, so I'm defining a polymer object like this:

<link rel="import" href="../bower_components/polymer/polymer.html">

<polymer-element name="my-element" attributes="content">
  <template>
  <div class="someclass">
    {{content}}
  </div>
</template>

<script>
  Polymer({});
</script>
</polymer-element>

Which works fine if I instantiate it as:

<my-element content="test"></my-element>

However, I'd like to be able to pass HTML inside the element. If I do this:

<my-element content="<div>test</div>"></my-element>

The HTML is not added to the DOM, but displayed as text. Is it possible to pass HTML inside a polymer element? Or am I doing something completely wrong here?

Thanks for any help!

Upvotes: 1

Views: 474

Answers (1)

Neil John Ramal
Neil John Ramal

Reputation: 3734

Here's some hackish code I made that may answer your question.

http://jsbin.com/hedutu/edit?html,output

Basically, I created an observer for an attribute that accepts DOMs in string format and then inserted that dom into a local dom node.

Upvotes: 2

Related Questions