Loop each x elements
Posted
by Cimm
on Stack Overflow
See other posts from Stack Overflow
or by Cimm
Published on 2010-03-22T09:52:45Z
Indexed on
2010/03/22
10:01 UTC
Read the original article
Hit count: 157
What's the beste way to show a list with 20 images in rows of 5? Or, in other words, how do I clean up this ugly snippet?
<div class="row">
<% @images.each_with_index do |image, index| %>
<%= image_tag image.url %>
<% if index != 0 && index % 5 == 0 %>
</div><div class="row">
<% end %>
<% end %>
</div>
© Stack Overflow or respective owner