How to check the size of list in sightly?

Avatar

Avatar

Dinu_Arya

Avatar

Dinu_Arya

Dinu_Arya

15-10-2015

[Thread Edited By Adobe]

/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here

Go ahead and to it now: https://adobe.ly/3eDnB4v */

 

Actual Post:

Hi,

I need to check size of the list in sightly. I need to display UI only when it has more than 2 items in list. Any idea?

Thanks,

Arya.

View Entire Topic

Avatar

Avatar

hemantbellani-O

Avatar

hemantbellani-O

hemantbellani-O

18-09-2017

// The WCMUse class' method that gives me an ArrayList

public List<String> getAllColumns() {

  List<String> allColumns = new ArrayList<String>();

  for (int i = 1; i <= 10; i++) {

    allColumns.add("Test" + "-" + i);

  }

  return allColumns;

  }

 

  # sightly code that I am trying out ....

<sly data-sly-list.myList="${myWCMUseObject.allColumns}">

  <div data-sly-test="${myList.size > 5}" data-sly-unwrap>

  Heloo!!!!!

        </div>

</sly>