Sightly: check for empty lists

Markus Haack picture Markus Haack · Jan 8, 2015 · Viewed 9.9k times · Source

Using data-sly-list I can iterate over a list object in Sightly, but how can I check if a list is empty? data-sly-list simply renders nothing on empty list objects and I need to display an alternativ text if the list contains no items.

Thanks

Answer

Tomek Rękawek picture Tomek Rękawek · Jan 8, 2015

Use data-sly-test and ! operator:

<div data-sly-test="${!myList}">List is empty</div>