Showing posts with label sightly tutorials. Show all posts
Showing posts with label sightly tutorials. Show all posts

Friday 10 February 2017

Sightly/ HTL Tips

 Sightly Tips

For SIghtly Tutorial Visit our help page : http://aem-cq-tutorials.blogspot.com/p/htl-home.html


? Sightly comparing a string value
Say we have a string 'heroType' and having some values. We need to test its value to 'AL', we can use below code to compare it.

<div data-sly-test="${style.getHeroType == 'AL' }">Hello</div>

? Check a list's(formatList) size using below code
<sly data-sly-test.emptysize ="${subcategoryUse.formatList.size > 0 }" />

--------------Similar Posts:----------
-------------------------------------------

? Check a list item count is greater than zero in sightly
Java List : shopList; Use class : subcategoryUse

<sly data-sly-list.listItem="${subcategoryUse.shopList}">
 <sly data-sly-test.count="${listItemList.index > 0}">
 //Do your task here if count is more than zero
 </sly>

? Passing a value to Use  class from sightly:
 <sly    data-sly-use.integerUse="${'com.....IntegerUse' @ text=item}">

 And in Use class IntegerUse.java read it as,
 String text = get("text", String.class);

 ? Iterating over a list
 Java List: firstList

 <sly data-sly-list="${quantumUse.firstList}">
 //Use list item here using '{item}'
 </sly>

 ? When a Java list contains an object holding multiple values, each value can be retrieved as below
 <a x-cq-linkchecker="valid" href="${listItem.getUrl}.html"><img src="${listItem.getitemImage}" class="image-responsive"></a>
 or
 <p>${listItem.getpriceInteger} <span>${listItem.getpriceDecimal}</span>

 ? Test multiple items in sightly

 <sly data-sly-test="${listItem.selectLogo && listItem.displayLogo}">
 OR
<div data-sly-test="${listItem.selectCategoryBadge.length > 0 && listItem.displayCategoryBadge}"