Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 911
mjs Avatar asked Jan 01 '26 03:01

mjs


1 Answers

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>.

like image 60
robdodson Avatar answered Jan 06 '26 02:01

robdodson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!