breadcrumbs_helper.rb 735 Bytes
Newer Older
1
module BreadcrumbsHelper
Phil Hughes's avatar
Phil Hughes committed
2
  def add_to_breadcrumbs(text, link)
3
4
5
6
7
8
9
10
11
12
    @breadcrumbs_extra_links ||= []
    @breadcrumbs_extra_links.push({
      text: text,
      link: link
    })
  end

  def breadcrumb_title_link
    return @breadcrumb_link if @breadcrumb_link

13
    request.path
14
  end
15
16
17
18
19
20

  def breadcrumb_title(title)
    return if defined?(@breadcrumb_title)

    @breadcrumb_title = title
  end
21
22
23

  def breadcrumb_list_item(link)
    content_tag "li" do
Phil Hughes's avatar
Phil Hughes committed
24
      link + icon("angle-right", class: "breadcrumbs-list-angle")
25
26
    end
  end
27
28
29

  def add_to_breadcrumb_dropdown(link, location: :before)
    @breadcrumb_dropdown_links ||= {}
Phil Hughes's avatar
Phil Hughes committed
30
    @breadcrumb_dropdown_links[location] ||= []
31
32
    @breadcrumb_dropdown_links[location] << link
  end
33
end