Class: AbAdmin::MenuGroup

Inherits:
BaseMenuGroup show all
Defined in:
lib/ab_admin/menu_builder.rb

Instance Method Summary collapse

Methods inherited from BaseMenuGroup

#group, #link, #model, #render_nested

Methods included from Utils::EvalHelpers

#call_method_or_proc_on, #evaluate_method

Constructor Details

#initialize(title, options, &block) ⇒ MenuGroup

Returns a new instance of MenuGroup.



49
50
51
52
53
54
# File 'lib/ab_admin/menu_builder.rb', line 49

def initialize(title, options, &block)
  @menu_tree = []
  @title = title.is_a?(Symbol) ? I18n.t(title, :scope => [:admin, :navigation]) : title
  @options = options
  instance_eval &block if block_given?
end

Instance Method Details

#render(template) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ab_admin/menu_builder.rb', line 56

def render(template)
  return if @options[:if] && !call_method_or_proc_on(template, @options[:if])
  return if @options[:unless] && call_method_or_proc_on(template, @options[:unless])

  <<-HTML.html_safe
      <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#" >#{@title}<b class="caret"></b></a>
        <ul class="dropdown-menu">#{render_nested(template)}</ul>
      <li>
  HTML
end