如何找到一个视线列表的大小 [英] How to find the size of a sightly list

查看:21
本文介绍了如何找到一个视线列表的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要仔细检查列表的大小.我尝试过 resource.size、item.size、itemList.size、resource.listChildren.size、item.listChildren.size,但这些都不起作用.

I need to check the size of list in sightly. I have tried resource.size, item.size, itemList.size, resource.listChildren.size, item.listChildren.size, but none of these works.

我打算使用 Java USE-API,但我不知道如何开始.

I'm planning to use Java USE-API, but I have no clue how to start.

<sly data-sly-list="resource.listChildren">
    <sly data-sly-list="item.listChildren">
        ${itemList.count} / #I need the total count of item here#
    </sly>
</sly>

推荐答案

自从 Resource#listChildren 将返回一个Iterator,您将无法从那里获得子项列表的大小.

Since Resource#listChildren will return an Iterator<Resource>, you will not be able to get the size of the list of children from there.

HTL 也不提供获取列表大小的方法,但它允许获取 当前项目的有趣属性:

HTL does not offer a way to get the list size either, however it allows getting interesting properties of the current item:

* index: zero-based counter (0..length-1);
* 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 count is odd;
* even: true if count is even.

这篇关于如何找到一个视线列表的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆