Module: Kadmin::NavigationHelper

Defined in:
app/helpers/kadmin/navigation_helper.rb

Instance Method Summary collapse

Instance Method Details

Generates a navigation drop down for bootstrap

Parameters:

  • prompt (String)

    dropdown prompt

  • links (Array<Hash,String>) (defaults to: [])

    list of links to add within the dropdown



16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/kadmin/navigation_helper.rb', line 16

def dropdown(prompt, links = [])
  button_content = (:span, '', class: 'caret').prepend(prompt)
  button = button_tag(button_content, type: 'button', data: { toggle: 'dropdown' }, class: 'btn btn-sm')
  list = (:ul, '', class: 'dropdown-menu') do
    links.reduce(ActiveSupport::SafeBuffer.new) do |buffer, link|
      buffer + (:li, link)
    end
  end

  return (:div, button + list, class: 'dropdown', style: 'display: inline-block;')
end

Generates HTML for a bootstrap navigation link

Parameters:

  • title (String)

    the navigation text

  • path (Hash, String)

    the path for the link

  • block (Proc)

    optional block to include content within the link



7
8
9
10
11
# File 'app/helpers/kadmin/navigation_helper.rb', line 7

def nav_link_to(title, path, &block)
  css_classes = []
  css_classes << 'active' if request.path.starts_with?(path)
  return (:li, link_to(title, path, &block), class: css_classes.join(' '))
end