node.js - How to render jade layout with loop of users -
i trying render it:
<div class="row"> <div class"test"> user 1 </div> <div class"test"> user 2 </div> <div class"test"> user 3 </div> </div> <div class="row"> <div class"test"> user 4 </div> <div class"test"> user 5 </div> <div class"test"> user 6 </div> </div>
i need 3 .test each .row:
- var count = 0 div.row user in users - count++ -if ((count % 3) == 0) div.test | #{user.name} div.row -else div.test | #{user.name}
but, not working because when loop try render "div.row" automatically close tag.
the wrong result is:
<div class="row"></div> <div class="test">user 1</div> <div class="test">user 2</div> <div class="test">user 3</div> <div class="row"></div> <div class="test">user 4</div> <div class="test">user 5</div> <div class="test">user 6</div> <div class="row"></div>
one of possible ways reorganize users array before send jade.
users = [[user1,user2,user3],[user4,user5,user6],...
and in jade
for group in users div.row user in group div.test | #{user.name}
Comments
Post a Comment