Module: BootstrapHelper

Defined in:
lib/trap/helpers/bootstrap_helper.rb

Instance Method Summary collapse

Instance Method Details



2
3
4
5
6
7
8
9
10
# File 'lib/trap/helpers/bootstrap_helper.rb', line 2

def menu_item(name = nil, path = '#', *args, &block)
  path = name || path if block_given?
  options = args.extract_options!
  options[:class] = [options[:class], 'nav-link'].join(' ')
   :li, class: "nav-item #{is_active?(path, options)}" do
    name, path = path, options if block_given?
    link_to name, path, options, &block
  end
end

#model_menu_item(model:, route:, icon: nil, number: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/trap/helpers/bootstrap_helper.rb', line 12

def model_menu_item(model:, route:, icon: nil, number: nil)
  title = model.is_a?(Class) ? model.model_name.human.pluralize(:ru) : model
  if icon
    menu_item route do
      concat icon_element icon
      concat ' '
      concat title
      if number && number != 0
        concat ' '
        concat((:span, number.to_s, class: 'badge danger'))
      end
    end
  else
    menu_item title, route
  end
end