Class: RocketNavigation::Renderer::List
- Defined in:
- lib/rocket_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 (based on the level and expand_all options), it renders another <ul> containing the sub navigation inside the active <li> element.
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
#active_tag_for, #base_item_html, #base_link_html, #consider_sub_navigation?, #container_html, #container_options, #expand_all?, #expand_sub_navigation?, #include_sub_navigation?, #initialize, #item_classes, #item_extra_classes, #item_html, #item_options, #level, #link_classes, #link_extra_classes, #link_html, #link_options, #render_sub_navigation_for, #selected_class, #skip_if_empty?, #suppress_link?, #suppressed_tag_for, #tag_for
Constructor Details
This class inherits a constructor from RocketNavigation::Renderer::Base
Instance Method Details
#list_content(item_container) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/rocket_navigation/renderer/list.rb', line 36 def list_content(item_container) ret = ActiveSupport::SafeBuffer.new item_container.items.each do |item| ret << render_item(item) end ret end |
#render(item_container) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/rocket_navigation/renderer/list.rb', line 18 def render(item_container) if skip_if_empty? && item_container.empty? ''.html_safe else tag = [:ordered] ? :ol : :ul content = list_content(item_container) content_tag(tag, content, container_html) end end |
#render_item(item) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rocket_navigation/renderer/list.rb', line 28 def render_item(item) li_content = tag_for(item) if (item) li_content << (item) end content_tag(:li, li_content, (item)) end |