Hi,
If you need to conditionally inject the component only once, you can use the data-sly-test
attribute:
<sly data-sly-test="${!injected}">
<sly data-sly-resource="${ 'component' @ resourceType='my/component/path' }"></sly>
<sly data-sly-use.injected="true"></sly>
</sly>
<!-- Your repeat logic for paragraphs -->
<sly data-sly-repeat.paragraph="${grid.paragraphs}">
<div>
<!-- Render paragraph content -->
<sly data-sly-resource="${paragraph.path @ resourceType=paragraph.resourceType, decorationTagName='div', cssClassName=paragraph.cssClass}"></sly>
</div>
</sly>
'injected' value is false or undefined then the injects the component and once it is executed `injected` value will be set to true avoid further injecting. Ensure the data-sly-repeat
loop for paragraphs is separate from the component injection logic. This way, the component is not included within the loop, avoiding duplication.