Module: MmmenuHelper

Defined in:
lib/generators/templates/helpers/mmmenu_helper.rb

Instance Method Summary collapse

Instance Method Details

#build_mmmenu(menu, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/templates/helpers/mmmenu_helper.rb', line 3

def build_mmmenu(menu, options = {})
  return nil unless menu
  options = {templates_path: 'mmmenu' }.merge(options)
  templates_path = options[:templates_path]
  menu.item_markup(1) do |link, text, options|
    render(:partial => "#{templates_path}/item", :locals => { :link => link, :text => text, :options => options })
  end
  menu.current_item_markup(1) do |link, text, options|
    render(:partial => "#{templates_path}/current_item", :locals => { :link => link, :text => text, :options => options })
  end
  menu.level_markup(1) { |m| render(:partial => "#{templates_path}/level_1", :locals => { :menu => m }) }
  menu.level_markup(2) { |m| render(:partial => "#{templates_path}/level_2", :locals => { :menu => m }) }
  menu.build.html_safe
end