Module: Edgarj::MenuHelper

Includes:
MenuConfig
Defined in:
app/helpers/edgarj/menu_helper.rb

Overview

draw Edgarj menu based on application’s menu configuration at config/edgarj/menu_config.rb.

Edgarj::MenuConfig should have ‘top’ module-function which returns arrays each entry is one of the followings:

  • item which contains link_to arg

  • controller menu list which contains controller name

    • special entry is ‘_separator’ which is not controller name, rather generates just menu separator.

See test/dummy/config/edgarj/menu_config.rb as an example.

SEE ALSO

draw_menu

method to draw menu

FILE

config/initializer/menu.rb

menu configuration at application

Instance Method Summary collapse

Instance Method Details

#draw_menuObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/edgarj/menu_helper.rb', line 23

def draw_menu
  (:ul, :id=>'edgarj_menu', :class=>'edgarj_menu') do
    out = ''
    for menu in Edgarj::MenuConfig.top
      out += (:li) do
        case menu[0]
        when :item
          draw_item(*menu[1])
        when :controller
          draw_controller_menu(menu[1], menu[2], menu[3])
        else
          "unknown menu type: #{menu[0]}"
        end
      end
    end
    out.html_safe
  end
end