Class: SimpleNavigation::Renderer::BootstrapTopbarList
- Inherits:
-
Base
- Object
- Base
- SimpleNavigation::Renderer::BootstrapTopbarList
- Defined in:
- lib/shoehorn/plugins/simple_navigation/renderer/bootstrap_topbar_list.rb
Overview
Renders an ItemContainer as a <ul> element and its containing items as <li> elements. Prepared to use inside the topbar of Twitter Bootstrap twitter.github.com/bootstrap/#navigation
Examples
(level: 1..2, renderer: :bootstrap_topbar_list, expand_all: true)
Instance Method Summary collapse
Instance Method Details
#render(item_container) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shoehorn/plugins/simple_navigation/renderer/bootstrap_topbar_list.rb', line 9 def render(item_container) if [:is_subnavigation] ul_class = "dropdown-menu" else ul_class = "nav" end list_content = item_container.items.inject([]) do |list, item| = item..reject {|k, v| k == :link} if (item) [:class] = [[:class], "dropdown"].flatten.compact.join(' ') end li_content = tag_for(item) if (item) li_content << (item) end list << content_tag(:li, li_content, ) end.join if skip_if_empty? && item_container.empty? '' else content_tag(:ul, list_content, { :id => item_container.dom_id, :class => [item_container.dom_class, ul_class].flatten.compact.join(' ') }) end end |
#render_sub_navigation_for(item) ⇒ Object
34 35 36 |
# File 'lib/shoehorn/plugins/simple_navigation/renderer/bootstrap_topbar_list.rb', line 34 def (item) item..render(self..merge(:is_subnavigation => true)) end |