Reputation: 3
I am using playFramework 2.1
I would like to break a for loop in a playFramework template.
This is my Code :
@breakable {
@for((item, count) <- list.zipWithIndex) {
<tr>
<td>@item.id</td>
<td>...</td>
</tr>
@if(count > 5){
@println("break")
@break
}
}
}
But It doesn't work - it displays nothing html tag. It only works for println
play console.
Upvotes: 0
Views: 1101
Reputation: 45
I'm not sure how you could create this custom tag (I'm kind of new to Play as well), but in this case, you can add a filter to the for statement:
@for((item, count) <- list.zipWithIndex if count <= 5) {
<tr>
<td>@item.id</td>
<td>...</td>
</tr>
@if(count > 5){
@println("break")
@break
}
}
Hope that helps!
Upvotes: 2