Sha256: 7ae5bdc80079adb273e432fb942ae1273bcd46baef7129ea40cec2224817226e
Contents?: true
Size: 761 Bytes
Versions: 3
Compression:
Stored size: 761 Bytes
Contents
module NavigationHelper def nav_link(text, link_path, options = {}, &block) link_options = options.fetch(:link_options, {}) link_options[:class] = link_classes(link_path, link_options) list_options = options.fetch(:list_options, {}) inner = capture(&block) content_tag(:li, list_options) do concat(link_to(text.html_safe, link_path, link_options)).concat( block_given? ? inner : "" ) end end def active_if_current_page(path, class_name = 'active') current_page?(path) ? class_name : "" end private def link_classes(link_path, options) classes = options.fetch(:class, "") active_class = active_if_current_page(link_path, options.fetch(:active, "active")) "#{classes} #{active_class}".strip end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_toolbelt-0.1.00 | app/helpers/navigation_helper.rb |
bootstrap_toolbelt-0.0.11 | app/helpers/navigation_helper.rb |
bootstrap_toolbelt-0.0.10 | app/helpers/navigation_helper.rb |