HTL data-sly-test

Avatar

Avatar

ariellea4070516

Avatar

ariellea4070516

ariellea4070516

14-12-2018

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

Replies

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

14-12-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

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

884

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

884
Arun_Patidar
MVP

15-12-2018

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

16-12-2018

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

In your case check if your item has these methods.

Avatar

Avatar

ariellea4070516

Avatar

ariellea4070516

ariellea4070516

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