开发者

Rails 3 view partial passing a block

I'd like to create a partial as follow:


%nav.tab_nav
  %ul
    %li.active
          %a
            Variable1
        %li
          %a
            Variable2
        %li
          %a
            Variable...n

Where variable1 variable2 etc exist, but the number of variables change, so I could traverse an array of arguments or something, but I don't know how to pass this array to the partial. Is there a wa开发者_Python百科y to pass a block or similar ?


Passing locals for partial:

= render :partial => "tabs", :locals => { :items => ["foo", "bar", "baz"] }

Looping part:

%nav
  %ul
    - items.each do |item|
      %li
        %a= item

http://guides.rubyonrails.org/layouts_and_rendering.html#passing-local-variables

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜