Module: Merrymenu::Helper

Defined in:
lib/merrymenu/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_menu(name = "menu", options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/merrymenu/view_helper.rb', line 4

def render_menu(name="menu", options={})
  options = options.symbolize_keys.reverse_merge!(:class => name)
  
  menu = Merrymenu::Builder.menus[name]
  return "" if menu.nil?
  
  tabs_html = ""
  
  menu.each do |tab|
    tabs_html << (:div, render_tab(tab), :class => tab_classes(tab)) if permit?(tab)
  end
  
  container_html = (:div, tabs_html.html_safe, :class => 'tabs')
  menu_html = (:div, container_html, :class => options[:class])
  menu_html
  
end

#render_tab(tab) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/merrymenu/view_helper.rb', line 22

def render_tab(tab)
  if Merrymenu.config.use_I18n_translation
    (:a, I18n.t(tab.name), :href => tab.url)
  else
    (:a, tab.name, :href => tab.url)
  end
end