Getting scala's template loop index in playframework -
i trying iterate in playframework view, without success now. have following structure:
@if(list != null) { for(a <- 0 list.size()/5) { // html, want value of for(b <- a*5 a*5+5) // here want use value again { html } }
so question how current index of loop able use it.
you should combine in 1 loop:
@if(list != null) { @for{a <- 0 list.size()/5 b <- a*5 a*5+5} yield html } }
and use option instead of null
checking. can use map
function transform list. see details in play documentation - http://www.playframework.com/documentation/2.0/scalatemplates
Comments
Post a Comment