代码之家  ›  专栏  ›  技术社区  ›  P Varga

在Marko模板中使用组件/标记内容

  •  1
  • P Varga  · 技术社区  · 7 年前

    假设我想要一个封装其内容的组件(也称为children):

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

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

    如何访问模板中的内容?

    2 回复  |  直到 7 年前
        1
  •  1
  •   Jessé Pinheiro    7 年前

    或者一个简单的解决方案:

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

       <my-article heading='Test'>
          Lorem ipsum <s>dolor</s> sit amet
       </my-article>
    
        2
  •  1
  •   P Varga    7 年前

    找到了解决方案- <include>

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

    然后像这样使用:

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