Sha256: dc4066992b843280cd8605b44a00540bde90ceb94e72642f1b6a750505b19657
Contents?: true
Size: 1.75 KB
Versions: 22
Compression:
Stored size: 1.75 KB
Contents
module ConteRailsTemplate class NavigationRenderer < SimpleNavigation::Renderer::Base def render(item_container) if options[:is_subnavigation] ul_class = "child" else ul_class = "parent" end list_content = item_container.items.inject([]) do |list, item| li_options = item.html_options.reject {|k, v| k == :link} li_content = tag_for(item) if include_sub_navigation?(item) li_content << render_sub_navigation_for(item) end list << content_tag(:li, li_content, li_options) 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 def render_sub_navigation_for(item) item.sub_navigation.render(self.options.merge(:is_subnavigation => true)) end protected def tag_for(item) if item.url.nil? content_tag('span', item.name, link_options_for(item).except(:method)) else link_content = item.name if item.url == "javascript:void(0);" link_content = "#{item.name}<b class=\"caret\"></b>" end link_to(link_content, item.url, link_options_for(item)) end end # Extracts the options relevant for the generated link # def link_options_for(item) special_options = {:method => item.method}.reject {|k, v| v.nil? } link_options = item.html_options[:link] || {} opts = special_options.merge(link_options) opts[:class] = [link_options[:class], item.selected_class].flatten.compact.join(' ') opts.delete(:class) if opts[:class].nil? || opts[:class] == '' opts end end end
Version data entries
22 entries across 22 versions & 1 rubygems