Sha256: 483cf934ccfc21840bb56512333c493190d1ae96d18763646456005bea536ecc
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
module Storefront module ListHelper def nav(key, path = nil, attributes = {}, &block) condition = extract_condition!(attributes) return if condition == false text = widget_text(key, :nav) if attributes.has_key?(:current) current = attributes.delete(:current) == true else current = on_current_page?(path) end li_class = "primary-navigation-item" if current li_class << " active" attributes[:class] = [attributes[:class], "active"].compact.uniq.join(" ") end as = attributes.delete(:as) || :span li_class << " #{attributes.delete(:li_class)}" if attributes[:li_class] li_class = li_class.present? ? {:class => li_class} : nil separator = attributes.delete(:separator) checkbox = attributes.delete(:checkbox) == true result = capture_haml do haml_tag :li, li_class do if checkbox haml_tag :label, text.strip haml_tag :input, :type => "checkbox" else if block_given? case block.arity when 1 yield(text.strip) else yield end elsif current && as == :span haml_tag :span, text.strip, attributes else haml_concat link_to(text.strip, path, attributes) end end haml_tag :span, separator if separator end end result end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
storefront-0.2.1 | lib/storefront/helpers/list_helper.rb |
storefront-0.2.0 | lib/storefront/helpers/list_helper.rb |