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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -