|
# Renders an ItemContainer as a <ul> element and its containing items as |
|
# <li><a> elements. |
|
# It only renders 'selected' elements. |
|
# |
|
# It's suited to work with foundation 5 out of the box |
|
class FoundationBreadcrumbs < SimpleNavigation::Renderer::Base |
|
|
|
# logic from SimpleNavigation::Renderer::List |
|
def render(item_container) |
|
if skip_if_empty? && item_container.empty? |
|
'' |
|
else |
|
tag = options[:ordered] ? :ol : :ul |
|
|
|
dom_attributes = item_container.dom_attributes |
|
if dom_attributes[:class] |
|
dom_attributes[:class] += " breadcrumbs" |
|
else |
|
dom_attributes[:class] = "breadcrumbs" |
|
end |
|
|
|
content = list_content(item_container) |
|
content_tag(tag, content, dom_attributes) |
|
end |
|
end |
|
|
|
private |
|
|
|
def list_content(item_container) |
|
li_tags(item_container).join |
|
end |
|
|
|
# logic from SimpleNavigation::Renderer::Breadcrumbs |
|
def li_tags(item_container) |
|
item_container.items.each_with_object([]) do |item, list| |
|
next unless item.selected? |
|
|
|
li_options = item.html_options.except(:link) |
|
li_content = tag_for(item) |
|
list << content_tag(:li, li_content, li_options) |
|
|
|
if include_sub_navigation?(item) |
|
list.concat li_tags(item.sub_navigation) |
|
end |
|
end |
|
end |
|
|
|
|
|
protected |
|
|
|
# from SimpleNavigation::Renderer::Breadcrumbs |
|
def suppress_link?(item) |
|
super || (options[:static_leaf] && item.active_leaf_class) |
|
end |
|
|
|
end |