AEM - 数据狡猾资源子html

问题描述 投票:0回答:2

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

比较一下,它会像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>
aem
2个回答
1
投票

此功能不存在。

您可以使用data-sly-template创建类似的功能。但是你必须将HTML sting作为参数(更具体地说是option)传递,但这可能不是所希望的或可维护的。


1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.