Sha256: f0f94a2c09b8f9ca49e12aee705c4f6aa620f824eb3aff619987739c67f70112
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
module SimpleNavigation module Renderer class SemanticUi < SimpleNavigation::Renderer::Base def render(item_container) config_selected_class = SimpleNavigation.config.selected_class SimpleNavigation.config.selected_class = 'active' list_content = item_container.items.inject([]) do |links, item| icon = item.html_options.delete(:icon) links << tag_for(item, item.name, icon) end.join SimpleNavigation.config.selected_class = config_selected_class if skip_if_empty? && item_container.empty? '' else content_tag(:div, list_content, {:id => item_container.dom_id, :class => item_container.dom_class}) end end protected def tag_for(item, name = '', icon = nil, split = false) unless item.url or include_sub_navigation?(item) return item.name end link = [] link << content_tag(:i, '', :class => [icon + ' icon']) unless icon.nil? link << name default_class = { link: { class: 'item' } } item.html_options = item.html_options.deep_merge(default_class) { |key, oldval, newval| "#{oldval} #{newval}" } link_to(link.join(" ").html_safe, item.url, options_for(item)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems