【问题标题】:AEM - data-sly-resource children htmlAEM - 数据狡猾的资源儿童html
【发布时间】:2019-04-03 19:03:51
【问题描述】:

我想找到一种将 HTML 插入 <sly data-sly-resource> 标记内的方法,并能够进入我从资源属性中检索的组件。

比较一下,类似于 Vue 的 slots 和 React 的 { this.props.children }

例子:

父组件

<sly data-sly-resource="${'example' @ resourceType='path/to/component/structure/example'}">
    <h1>Hello World</h1>
</sly>

示例组件

<div id="example-component">
    ${ variable.getChildrenHTMLCall() } // Does something like this exist?
</div>

输出

<div id="example-component">
    <h1>Hello World</h1>
</div>

【问题讨论】:

  • 此功能不存在。您可以使 similar 功能与 data-sly-template 一起使用,但您必须将 html 字符串作为参数而不是作为可能不需要或不可维护的子元素传递。
  • 也许添加您的评论作为答案,@AhmedMusallam?

标签: aem


【解决方案1】:

此功能不存在。

可以使用data-sly-template 制作类似的功能。但是您必须将 HTML 字符串作为参数传递(更具体地说是 option),但这可能是不可取的或不可维护的。

【讨论】:

    【解决方案2】:

    您可以使用com.day.cq.contentsync.handler.util.RequestResponseFactory,如下所示:http://www.nateyolles.com/blog/2015/10/get-rendered-html-for-an-aem-resource-or-component

    【讨论】:

      猜你喜欢
      • 2018-03-16
      • 1970-01-01
      • 2015-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多