Sha256: 1f2945d6a31cc344ba3d1c264775d4436ea9e694d17260ba76d0f1aecfd38ee6
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module MenuMaker class CustomMenuRenderer < MenuRenderer render do out = build_menu do |item, css_class| output = build_html do |html| html << render_link(item) if item.has_submenu? css_class << 'dropdown' html << item.submenu.render end html end if item.has_path? current_path css_class << 'active open' end options = css_class.any? ? { class: css_class.join(' ') } : {} h.li(output, nil, options) end h.content_tag(:ul, out, class: 'nav navbar-nav side-nav') end private def render_title(item) build_html do caret = item.has_submenu? ? ' <b class="caret"></b>' : '' i = %{<i class="#{item.icon}"></i>} "#{i} #{item.title}#{caret}" end end def render_link(item) if item.has_submenu? options = { class: 'dropdown-toggle', data: { toggle: 'dropdown' } } else options = {} end h.link_to(render_title(item), item.path, options) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
menu_maker-0.0.2 | lib/menu_maker/custom_menu_renderer.rb |
menu_maker-0.0.1 | lib/menu_maker/custom_menu_renderer.rb |