Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

HTL data-sly-test

Avatar

Level 3

Is there a way to test if listChildren will return anything? Something along the line of: <sly data-sly-test=${item.listChildren.size > 0} />

0 Replies

Avatar

Employee

You can call any method that has no arguments in data-sly-test.

In your case check if your item has these methods.

Avatar

Level 3

Thank you all! Your answers pointed me to a solution. I was able to test whether or not the item had children this way:

<sly data-sly-test=${item.listChildren.hasNext} />

Avatar

Level 8

This one did not work for me though the original check for item.children.size == 0 worked well

Avatar

Level 8

Just an update the data-sly-test="${item.children.size == 0} and data-sly-test="${item.children.size > 0} worked for me as intended.