Class: SimpleNavigation::Renderer::List
- Defined in:
- lib/simple_navigation/renderer/list.rb
Overview
Renders an ItemContainer as a <ul> element and its containing items as <li> elements. It adds the ‘selected’ class to li element AND the link inside the li element that is currently active.
If the sub navigation should be included, it renders another <ul> containing the sub navigation inside the active <li> element.
If the SimpleNavigation.config.render_all_levels option is set to true, it always renders all levels of navigation (fully expanded tree).
By default, the renderer sets the item’s key as dom_id for the rendered <li> element unless the config option autogenerate_item_ids
is set to false. The id can also be explicitely specified by setting the id in the html-options of the ‘item’ method in the config/navigation.rb file.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
controller_method, #initialize
Constructor Details
This class inherits a constructor from SimpleNavigation::Renderer::Base
Instance Method Details
#render(item_container, include_sub_navigation = false, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/simple_navigation/renderer/list.rb', line 15 def render(item_container, =false, ={}) list_content = item_container.items.inject([]) do |list, item| = item. li_content = link_to(item.name, item.url, :class => item.selected_class, :method => item.method) if item. if SimpleNavigation.config.render_all_levels || ( && item.selected?) || [:all] li_content << (item..render()) end end list << content_tag(:li, li_content, ) end content_tag(:ul, list_content.join, {:id => item_container.dom_id, :class => item_container.dom_class}) end |