Sightly - 清空清单 HTL [英] Sightly - Empty check on list HTL
问题描述
如何在Sightly上查看空列表?如果 itemImgaeList 上没有项目,我想阻止呈现项目列表 DIV.但是如果在尝试时没有项目,它总是会返回一 (1) 个 -
LIST_SIZE_PRINT = "${container.itemImgaeList.size}";//返回 1
HTL:
<div data-sly-test="${container.itemImgaeList.size >1}><sly data-sly-list.imageList=${container.itemImgaeList}"><div class="item-list"><图片><img alt="${imageList.qlImageText}";src="${imageList.qlImagePath}";/></图片>
</狡猾的>
有什么帮助吗?
data-sly-list 可用于实现上述仅在列表不为空时呈现列表元素的要求.
检查列表不需要使用data-sly-test",因为空检查是由 data-sly-list 固有地完成的.
这是一个使用 data-sly-list 的工作示例:
<图片><img alt="${item.qlImageText}";src="${item.qlImagePath}";/></图片>
更多信息:
https://www.aemquickstart.in/2016/08/htl-sightly-notes.html
How to check the empty list on Sightly? I wanted to prevent render the item-list DIV if there was no item on itemImgaeList. But it returns me one (1) always if there were no items while trying with -
LIST_SIZE_PRINT = "${container.itemImgaeList.size}"; // retrun 1
HTL:
<div data-sly-test="${container.itemImgaeList.size > 1}">
<sly data-sly-list.imageList="${container.itemImgaeList}">
<div class="item-list">
<picture>
<img alt="${imageList.qlImageText}" src="${imageList.qlImagePath}" />
</picture>
</div>
</sly>
</div>
Any help?
data-sly-list can be used for implementing the above requirement of rendering the list elements only when the list is not empty.
The use of 'data-sly-test' is not required for checking a list, as the check for emptiness is done inherently by data-sly-list.
Here is a working example using data-sly-list:
<div class="item-list" data-sly-list.item="${container.itemImgaeList}">
<picture>
<img alt="${item.qlImageText}" src="${item.qlImagePath}" />
</picture>
</div>
More information:
https://www.aemquickstart.in/2016/08/htl-sightly-notes.html
这篇关于Sightly - 清空清单 HTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!