Module: NdrUi::Bootstrap::DropdownHelper

Included in:
NdrUi::BootstrapHelper
Defined in:
app/helpers/ndr_ui/bootstrap/dropdown_helper.rb

Overview

This provides bootstrap dropdown helper methods

Instance Method Summary collapse

Instance Method Details

#bootstrap_list_divider_tag(options = {}) ⇒ Object

Creates a Boostrap list divider.

Signatures

bootstrap_list_divider_tag

Examples

<%= bootstrap_list_divider_tag %>
# => <li class="divider"></li>


59
60
61
62
# File 'app/helpers/ndr_ui/bootstrap/dropdown_helper.rb', line 59

def bootstrap_list_divider_tag(options = {})
  options[:class] = (options[:class].to_s.split(' ') + ['divider']).join(' ')
  (:li, '', { role: 'presentation' }.merge(options))
end

#bootstrap_list_header_tag(name, options = {}) ⇒ Object

Creates a Boostrap list header.

Signatures

bootstrap_list_header_tag(name)

Examples

<%= bootstrap_list_header_tag("Apples") %>
# => <li class="dropdown-header">Apples</li>


44
45
46
47
# File 'app/helpers/ndr_ui/bootstrap/dropdown_helper.rb', line 44

def bootstrap_list_header_tag(name, options = {})
  options[:class] = (options[:class].to_s.split(' ') + ['dropdown-header']).join(' ')
  (:li, name, { role: 'presentation' }.merge(options))
end

Creates an html list item containing a link. It takes the standard link_to arguments passing them through to a standard link_to call. For bootstrap styling, it simply adds the class “active”, if the link points to the current page that is being viewed. Predominantly used by nav bars and lists.

Signatures

bootstrap_list_link_to(name, options = {}, html_options = nil)
bootstrap_list_link_to(options = {}, html_options = nil) do
  # name
end

See the Rails documentation for details of the options and examples



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/ndr_ui/bootstrap/dropdown_helper.rb', line 19

def bootstrap_list_link_to(*args, &block)
  if block_given?
    return bootstrap_list_link_to(capture(&block), (args.first || {}), args.second)
  end

  name         = args.first
  options      = args.second || {}
  html_options = args.third
  li_options   = {}

  li_options[:class] = 'active' if current_page?(options)

  (:li, link_to(name, options, html_options), li_options)
end