Haml/Ruby/Rails adding an element conditionally? -
i have code:
- userlist.each |member| = render :partial => 'projects/member_small', :locals => { :user => member }
and want add div element every 2 times |member| occurs. every 2 times. want this:
- userlist.each |member| .row = render :partial => 'projects/member_small', :locals => { :user => member }
you slice list groups of two:
- userlist.each_slice(2) |group| .row - group.each |member| = render :partial => 'projects/member_small', :locals => { :user => member }
Comments
Post a Comment