Use component/tag contents in Marko template

102 Views Asked by At

Say I'd like to have a component that wraps its contents (aka children):

<article>
  <header>${input.heading}</header>
  <section> ... contents come here ... </section>
<article>

Then use it like:

...
<my-article heading='Test'>
  Lorem ipsum <s>dolor</s> sit amet
</my-article>

How do I access the contents in the template?

2

There are 2 best solutions below

0
On BEST ANSWER

Or a simple solution:

<article>
  <header>${input.heading}</header>
  <section><include(input) /></section>
<article>

And use:

   <my-article heading='Test'>
      Lorem ipsum <s>dolor</s> sit amet
   </my-article>
1
On

Found the solution - <include> reusable/nested content:

<article>
  <header>${input.heading}</header>
  <section><include(input.body) /></section>
</article>

Then use it like:

<my-article heading='Hello'>
  <@body>Lorem ipsum dolor sit <u>amet</u></@body>
</my-article>