views:

49

answers:

1

I have some code:

- count = 0
- @clients.each do |client|
  %div{:class => "grid_2#{(" alpha" if (count % 3) == 0) || (" omega push_2" if (count % 3) == 2) || " push_1"}"}= link_to h(client.name), client    
  - count += 1

I want to output an opening div tag right after the each statement if the (count % 3) == 0 and out put the end tag at the end of the block if the (count % 3) == 2 but I can't figure out how to get HAML to do this. Any ideas?

A: 

This is a nice solution that was posted here a few weeks ago. It's not in Haml, but the idea is the same.

http://stackoverflow.com/questions/2851915/rails-each-loop-insert-tag-every-6-items

jdl
That's great thanks
trobrock