Hi,
I have requirement of below script.
<div class="${object.ColumnContainerClass}">
<sly data-sly-list="${object.ColumnSubContainerClass}" >
<div class="${item @CONTEXT='text'}">
</sly>
Random code ...........
<sly data-sly-list="${object.ColumnSubContainerClass}">
</div>
</sly>
</div>
but I am unable to get the </div> class inside sly. even if ColumnSubContainerClass is empty div renders on the page. Please help.
Thanks in Advance
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Looks like you want outer div only if the object.ColumnSubContainerClass is not empty. you can achieve it using using data-sly-unwrap but you have to use it only if you want to print inner "Random code" even if the ColumnSubContainerClass is empty.
The Empty div is printing when object.ColumnSubContainerClass is empty because data-sly-list iterates once even if the value is empty. If you want to avoid it. check its value first using data-sly-test like
<div class="${object.ColumnContainerClass}">
<sly data-sly-test="${object.ColumnSubContainerClass}" data-sly-list="${object.ColumnSubContainerClass}" >
<div class="${item @CONTEXT='text'}">
Random code ...........
</div>
</sly>
</div>
Try this out. Let me also know if your usecase is different.
Hope it helps!
Nupur.
Hi,
What is your requirement, do you need to add all the classes to one div or need to generate multiple divs based on the list item.
Can you please share HTL and HTML example
Views
Replies
Total Likes
Views
Replies
Total Likes
Looks like you want outer div only if the object.ColumnSubContainerClass is not empty. you can achieve it using using data-sly-unwrap but you have to use it only if you want to print inner "Random code" even if the ColumnSubContainerClass is empty.
The Empty div is printing when object.ColumnSubContainerClass is empty because data-sly-list iterates once even if the value is empty. If you want to avoid it. check its value first using data-sly-test like
<div class="${object.ColumnContainerClass}">
<sly data-sly-test="${object.ColumnSubContainerClass}" data-sly-list="${object.ColumnSubContainerClass}" >
<div class="${item @CONTEXT='text'}">
Random code ...........
</div>
</sly>
</div>
Try this out. Let me also know if your usecase is different.
Hope it helps!
Nupur.
Views
Likes
Replies
Views
Likes
Replies