mjs
mjs

Reputation: 65363

How to access the body of a custom element from within a Polymer template?

I have a custom Polymer element <foo>. In its <template> element, how can I access the body of the <foo> element? That is, how do I arrange for:

<foo>
  <em>Clem</em>
</foo>

to be transformed into

Hello, <em>Clem</em>

via a <template> that will presumably look something like

<polymer-element name="foo">
  <template>
    Hello, ???
  </template>
</polymer-element>

Upvotes: 3

Views: 163

Answers (1)

robdodson
robdodson

Reputation: 6786

As ebidel points out in Custom Polymer element <x-strong> that works like the builtin <strong>?, you'll need to create an insertion point with the <content> tag.

I should also point out that your element name needs to contain a dash to meet the spec. So it should be <x-foo> or <my-foo>, not just <foo>.

Upvotes: 1

Related Questions