Skip to content

Commit

Permalink
Ensure nothing is rendered on skip_if_empty?
Browse files Browse the repository at this point in the history
Fixes #12
  • Loading branch information
pdf committed Feb 19, 2015
1 parent 1246eee commit d5bbaf8
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/simple_navigation/rendering/renderer/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module SimpleNavigation
module Renderer
class Bootstrap < SimpleNavigation::Renderer::Base
def render(item_container)
return '' if respond_to?(:skip_if_empty?) && skip_if_empty? && item_container.empty?
config_selected_class = SimpleNavigation.config.selected_class
SimpleNavigation.config.selected_class = 'active'
list_content = item_container.items.inject([]) do |list, item|
Expand All @@ -28,16 +29,13 @@ def render(item_container)
list << content_tag(:li, li_content, li_options)
end.join
SimpleNavigation.config.selected_class = config_selected_class
if skip_if_empty? && item_container.empty?
''
else
if item_container.respond_to?(:dom_attributes)
dom_attributes = item_container.dom_attributes
else
# supports simple-navigation before the ItemContainer#dom_attributes
dom_attributes = {:id => item_container.dom_id, :class => item_container.dom_class}
end
content_tag(:ul, list_content, dom_attributes)
if item_container.respond_to?(:dom_attributes)
dom_attributes = item_container.dom_attributes
else
# supports simple-navigation before the ItemContainer#dom_attributes
dom_attributes = {:id => item_container.dom_id, :class => item_container.dom_class}
end
content_tag(:ul, list_content, dom_attributes)
end
end

Expand Down

0 comments on commit d5bbaf8

Please sign in to comment.