Skip to content

Instantly share code, notes, and snippets.

@parndt
Forked from michaelward82/_menu_branch.html.erb
Created August 19, 2011 04:59
Show Gist options
  • Save parndt/1156082 to your computer and use it in GitHub Desktop.
Save parndt/1156082 to your computer and use it in GitHub Desktop.
Limit menu rendering in Refinery CMS
<%
if !!local_assigns[:apply_css] and (classes = menu_branch_css(local_assigns)).any?
css = "class='#{classes.join(' ')}'".html_safe
end
# dom_id DEPRECATED: REMOVE AT 1.1, serves no purpose same with css attributes 'first' and 'last'
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 -%>
<% if ( (children = menu_branch.children unless hide_children).present? &&
(!local_assigns[:menu_levels] || menu_branch.depth < local_assigns[:menu_levels]) ) -%>
<ul class='clearfix'>
<%= render :partial => '/shared/menu_branch', :collection => children,
:locals => {
:apply_css => local_assigns[:apply_css],
:hide_children => !!hide_children
}
-%>
</ul>
<% end -%>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment