Class: AbAdmin::MenuGroup
- Inherits:
-
BaseMenuGroup
- Object
- BaseMenuGroup
- AbAdmin::MenuGroup
- Defined in:
- lib/ab_admin/menu_builder.rb
Instance Method Summary collapse
-
#initialize(title, options, &block) ⇒ MenuGroup
constructor
A new instance of MenuGroup.
- #render(template) ⇒ Object
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, , &block) @menu_tree = [] @title = title.is_a?(Symbol) ? I18n.t(title, :scope => [:admin, :navigation]) : title @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 |