我想找出一种方法在<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>
此功能不存在。
您可以使用data-sly-template
创建类似的功能。但是你必须将HTML sting作为参数(更具体地说是option
)传递,但这可能不是所希望的或可维护的。
您可以使用com.day.cq.contentsync.handler.util.RequestResponseFactory
,如下所示:http://www.nateyolles.com/blog/2015/10/get-rendered-html-for-an-aem-resource-or-component