lib/ab_admin/menu/group.rb in ab_admin-0.5.0 vs lib/ab_admin/menu/group.rb in ab_admin-0.6.0
- old
+ new
@@ -12,13 +12,22 @@
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}<b class="caret"></b></a>
+ <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
+
+ private
+
+ def title(template)
+ return @title unless @options[:badge]
+ badge = call_method_or_proc_on(template, @options[:badge])
+ return @title if !badge || badge == 0
+ "#{@title} <span class='badge badge-#{@options[:badge_type] || 'important'}'>#{badge}</span>".html_safe
end
end
end
end