HTL data-sly-test | Community
Skip to main content
ariellea4070516
Level 3
December 15, 2018

HTL data-sly-test

  • December 15, 2018
  • 4 replies
  • 5602 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

smacdonald2008
Level 10
December 15, 2018

Good question - here is more explanation on test -- htl-spec/SPECIFICATION.md at master · adobe/htl-spec · GitHub

See Section -- 2.2.5. Test

arunpatidar
Community Advisor
Community Advisor
December 15, 2018
Feike_Visser1
Adobe Employee
Adobe Employee
December 17, 2018

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

In your case check if your item has these methods.

ariellea4070516
Level 3
December 17, 2018

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} />

Rohan_Garg
Community Advisor
Community Advisor
July 22, 2022

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

Rohan_Garg
Community Advisor
Community Advisor
July 22, 2022

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