samedi 25 juillet 2015

Thymeleaf: Iteration - increment by N and access list.get(N)

So I've read the Iterations part of the documentation already but still didn't give any idea on how to do the following:

Iterate per 2 records (since I am rendering something like below) and access list by index.

<div class="row">
   <div class="col-md-6">
      ...
   </div>
   <div class="col-md-6">
      ...
   </div>
</div>

Basically if this were in code, it looks something like

for (int i = 0; i < size;) {
    // do stuff

    // manual increment
    if (i + 2 > size) {
        i++;
    } else {
        i += 2;
    }
}

Aucun commentaire:

Enregistrer un commentaire