1
如何呈現特定的次數? 我讓我的topmenu和sidemenu擁有相同的頁面。我希望topmenu只顯示前4頁,並讓sidemenu顯示所有可用頁面。如何呈現特定的次數?
<%= render :partial => '/shared/menu_branch', :collection => roots, :locals => {
:hide_children => hide_children,
:sibling_count => (roots.length - 1),
:apply_css => true
} -%>
和menu_branch
<%
if !!local_assigns[:apply_css] and (classes = menu_branch_css(local_assigns)).any?
css = "class='#{classes.join(' ')}'".html_safe
end
dom_id = "id='item_#{menu_branch_counter}'".html_safe if menu_branch.parent_id.nil?
-%>
<li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '').html_safe %>>
<%= link_to menu_branch.title, menu_branch.url -%>
</li>
這是我想渲染只有4次就行了。
<li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '').html_safe %>>
<%= link_to menu_branch.title, menu_branch.url -%>
</li>