I have about 100 items that I use jade iteration to write each one of them to html. However, I'm struggling to find an elegant way to separate the items into rows of three.
To be clear, I want something like this:
.row
.item1
.item2
.item3
.row
.item1
... and so on...
I've tried things with inline javascript like this with no luck:
- var a = 0;
each item in list
- a++;
- if(a % 3 == 0)
.row-fluid
.span3(id='#{item.id}')
p #{item.id}
- else
.span3(id='#{item.id}')
p #{item.id}
note: this kills the list
while list.length > 0
.row
for item in list.splice(0, 3)
.span3(id=item.id)
p= item.id
let me know if this works as i just wrote it off the top of my head
- var i = -3;
while i <= list.length
- i += 3;
.row
each item in list.slice(i, i+3)
.span3(id='#{item.id}')