- Get link
- Other Apps
- Get link
- Other Apps
The
HTML Template Language (HTL) supported by Adobe Experience Manager (AEM) is the
preferred and recommended server-side template system for HTML in AEM. It takes
the place of JSP (JavaServer Pages) as used in previous versions of AEM. Below are the top 10 use cases which are commonly used while working with sightly:
1. Print current
page title :
${currentPage.title}
2. Use data-sly-test evaluation :
<sly
data-sly-test="${properties.jcr:title}">
${properties.jcr:title}
</sly
>
3. Include responsivegrid in slightly :
<sly data-sly-resource ="${'parsys' @resourceType= 'wcm/foundation/components/responsivegrid'}"></sly>
4. Integration with sling model :
<sly data-sly-use.model ="packagename.modelClassName"></sly>
5. Iterate a list :
<sly data-sly-list="${model.listObject}">
${item.name}
</sly>
6. Index of list :
<sly data-sly-list="${model.listObject}">
${itemList.index}
</sly>
index: zero-based counter (0..length-1)
some other useful list objects:
- count: one-based counter (1..length).
- first: true for the first element being iterated.
- middle: true if element being iterated is neither the first nor the last.
- last: true for the last element being iterated.
- odd: true if index is odd.
- even: true if index is even
7. Iterate map :
<sly data-sly-use.model="com.aem.project.core.models.Model"/>
<sly data-sly-set.myMap="${model.map}">
<p>key: ${ mapItem }</p>
<p>value: ${myMap[mapItem]}</p>
</sly>
</sly>
8. Include other files :
<sly data-sly-include="/libs/wcm/core/components/init/init.jsp"/>
9. Check edit mode :
<p data-sly-test="${wcmmode.edit}">You are in edit mode</p>
10. Include ClientLibs :
single clientlibs:
<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"
<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"
data-sly-call="${clientlib.all @ categories='myCategory'}"/>
multiple clientlibs:
<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"
data-sly-call="${clientlib.all @ categories=['myCategory1', 'myCategory2']}"/>
Hope this helps!!
Happy Coding 🙏
- Get link
- Other Apps
Comments
Useful blog, thanks for sharing
ReplyDeleteInformational,
DeleteThanks :)
DeleteThanks :)
ReplyDeleteGood work Bimmi. Keep it up. Looking forward for more.
ReplyDeleteThanks Paritosh :) will most more soon
Deletegood job
ReplyDeleteThank you :)
DeleteGood one..
ReplyDeleteThanks 😊
Delete