2

我有这个代码:

- userlist.each do |member|
  = render :partial => 'projects/member_small', :locals => { :user => member }

我想每两次添加一个 div 元素 do |member| 发生。所以基本上每两次。我要这个:

- userlist.each do |member|
  .row
    = render :partial => 'projects/member_small', :locals => { :user => member }
4

1 回答 1

6

您可以将列表分成两组:

- userlist.each_slice(2) do |group|
  .row
    - group.each do |member|
      = render :partial => 'projects/member_small', :locals => { :user => member }
于 2013-08-08T00:52:57.387 回答