Module: SimpleMenu::MenuHelper

Defined in:
lib/simple_menu.rb

Defined Under Namespace

Classes: MenuBuilder

Instance Method Summary (collapse)

Instance Method Details



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/simple_menu.rb', line 9

def menu_tag(name, options = {}, &block)
  options[:id] = name.to_s unless options[:id]
  seperator = options.delete(:seperator) || ""
  
  menu_object = MenuBuilder.new(@current_tab)
  output_menu = capture { block.call(menu_object) } || ""

  menu_object.items.map do |item|
    link = link_to(item.delete(:link_text), item.delete(:link_url), item.delete(:link_options))         
    link = "#{link} #{seperator}" unless menu_object.items.last?(item)

    output_menu << (:li, link, item)
  end

  concat (:ul, output_menu, options)    
end