Sha256: 6d57fa2e375f9ef3e1d29abed5018af35f12e5b1050b845664060654c0fb6ce0

Contents?: true

Size: 599 Bytes

Versions: 1

Compression:

Stored size: 599 Bytes

Contents

module MenuBuilder
  module ViewHelpers
    class Menu

      def initialize(context)
        @context = context
        @menu_item = @context.instance_variable_get('@menu_item')
      end

      def current_item?(item)
        @menu_item.to_s == item.to_s
      end

      def method_missing(item, *args, &block)
        css_class = "current" if current_item?(item)
        @context.content_tag :li, @context.link_to(*args, &block), :class=>css_class
      end

    end

    def menu(options={})
      concat tag(:ul, options, true)
      yield Menu.new(self)
      concat "</ul>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
menu_builder-0.2.0 lib/menu_builder/helper.rb