aemsightlyhtl

HTL data-sly-test for listChildren


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


Solution

  • Assuming this is a followup of Sightly Implicit Objects, the listChildren method will return an Iterator. You can check it’s not empty by calling its hasNext method:

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