Class: AbAdmin::Menu::Group
- Defined in:
- lib/ab_admin/menu/group.rb
Instance Method Summary collapse
-
#initialize(title, options, &block) ⇒ Group
constructor
A new instance of Group.
- #render(template) ⇒ Object
Methods inherited from BaseGroup
#group, #link, #model, #render_nested
Methods included from Utils::EvalHelpers
#call_method_or_proc_on, #evaluate_method
Constructor Details
#initialize(title, options, &block) ⇒ Group
Returns a new instance of Group.
4 5 6 7 8 9 |
# File 'lib/ab_admin/menu/group.rb', line 4 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
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ab_admin/menu/group.rb', line 11 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" href="#{@options[:url] || '#'}" >#{title(template)}<b class="caret"></b></a> <ul class="dropdown-menu">#{render_nested(template)}</ul> <li> HTML end |