Sha256: f53693acfccc307b2189ef1f6cffaee979cdb180d8e837884cb1c2cff2955cbf
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
module NavHelper NAV_CLASS = 'nav'.freeze NAV_TABS_CLASS = 'nav-tabs'.freeze NAV_PILLS_CLASS = 'nav-pills'.freeze NAV_CLASSES = [NAV_TABS_CLASS, NAV_PILLS_CLASS] def nav(options = {}, type = NAV_TABS_CLASS, &block) options, type = {}, options unless options.is_a?(Hash) options[:class] ||= [] options[:class] = [*options[:class]] options[:class].unshift(NAV_CLASS) unless options[:class].include?(NAV_CLASS) options[:class] << type unless NAV_CLASSES.any? { |c| options[:class].include?(c) } content_or_options_with_block = options if block_given? content_tag(:ul, content_or_options_with_block, options, &block) end alias_method(:tabs, :nav) def pills(*args, &block) nav(*args, NAV_PILLS_CLASS, &block) end def nav_to(name = nil, options = nil, html_options = nil, &block) if block_given? url_options, html_options = name, options else url_options = options end url_options ||= {} active = html_options.try(:delete, :active) active = current_page?(url_options) if active.nil? tab_class = active ? 'active' : nil content_tag(:li, role: 'presentation', class: tab_class) do link_to(name, options, html_options, &block) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bootstrap-sass-extras-0.1.0 | app/helpers/nav_helper.rb |