Module: LinkHelper

Includes:
FormatHelper
Defined in:
app/helpers/link_helper.rb

Instance Method Summary collapse

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Instance Method Details



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/link_helper.rb', line 38

def navbar_brand(name = nil, options = nil, html_options = nil, &block)
  html_options, options, name = options, name, block if block_given?
  options      ||= {}
  html_options ||= {}

  prepend_class(html_options, 'navbar-brand')

  if block_given?
    link_to options, html_options do
      yield name
    end
  else
    link_to name, options, html_options
  end
end


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/link_helper.rb', line 18

def navbar_link(name = nil, options = nil, html_options = nil, &block)
  html_options, options, name = options, name, block if block_given?
  options      ||= {}
  html_options ||= {}

  prepend_class(html_options, 'navbar-link')
  active = 'active' if html_options.delete(:active)


   :li, class: active do
    if block_given?
      link_to options, html_options do
        yield name
      end
    else
      link_to name, options, html_options
    end
  end
end


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/link_helper.rb', line 4

def navbar_link_to(name = nil, options = nil, html_options = nil, &block)
  html_options, options, name = options, name, block if block_given?
  options      ||= {}
  html_options ||= {}

  prepend_class(html_options, 'navbar-link')

  return link_to(name, options, html_options) unless block_given?

  link_to options, html_options do
    yield name
  end
end