Sha256: 9d4cc10efa3eeca59ae2284a3c2c1b09e3f593008e86b03d0ca59729bad8a0ad
Contents?: true
Size: 1.06 KB
Versions: 7
Compression:
Stored size: 1.06 KB
Contents
require "hashie" module Fume module SimpleNav def self.try_enable(app) ActionView::Base.send :include, HelperExtensions end module HelperExtensions def simple_nav(attr_reader_name) value = self.send(attr_reader_name) tag = SimpleNavTag.new({ :helper => self, :value => value, :active_class => "active" }) if block_given? yield tag return nil else return tag end end class SimpleNavTag < Hashie::Mash def li_tag(value, options = {}, &block) self.content_tag(value, :li, options, &block) end def content_tag(value, tag_name, options = {}, &block) if value == self.value if options[:class] options[:class] += " #{self.active_class}" else options[:class] = "#{self.active_class}" end end helper.content_tag(tag_name, options, &block) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems