Module: BreadcrumbHelper

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

Instance Method Summary collapse

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Instance Method Details



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

def breadcrumb(links=[], options={})
  return if links.blank?

  prepend_class(options, 'breadcrumb')

   :ol, options do
    links.map.with_index do |link, index|
      render_li(link, (index == links.length - 1))
    end.join('').html_safe
  end
end

#render_li(link, last_li) ⇒ Object



16
17
18
19
20
21
22
# File 'app/helpers/breadcrumb_helper.rb', line 16

def render_li(link, last_li)
  active = {class: 'active'} if last_li

   :li, active do
    last_li ? link[:text] : (link_to link.delete(:text), link.delete(:link), link)
  end
end