aem-6

Significance of @ in AEM slightly


Why we use @ symbol in AEM slightly code. What is the significance of @?

For example:

<section data-sly-resource="${'./path' @ resourceType='my/resource/type'}"></section> 

In above code why @ resourceType is used?


Solution

  • @ is used in HTL/Sightly to pass parameters to the HTL block statements https://experienceleague.adobe.com/docs/experience-manager-htl/using/htl/block-statements.html?lang=en#request-attributes

    If you check the above link you can see that the property settings.settings is passed as requestAttributes to the productdetails.html HTL file. It is same like passing arguments in a function, except that the syntax to do it in HTL/sightly is to use @ with the parameter name and value

    <sly data-sly-use.settings="com.adobe.examples.htl.core.hashmap.Settings"
            data-sly-include="${ 'productdetails.html' @ requestAttributes=settings.settings}" />