Module: BreadcrumbsHelper

Included in:
Kuppayam::BaseController
Defined in:
app/helpers/breadcrumbs_helper.rb

Instance Method Summary collapse

Instance Method Details

Initialize @links in your controller action



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/breadcrumbs_helper.rb', line 22

def breadcrumb
  if @breadcrumbs && @breadcrumbs.has_key?(:links) && @breadcrumbs[:links].any?
    (:div, class: "breadcrumb-env hidden-xs") do
      (:ol, class: "breadcrumb bc-1") do
        li_array = []
        @breadcrumbs[:links].each do |item|
          li_class = item[:active] == true ? "active" : ""
          li_array << (:li, class: li_class) do
            i_tag = item.has_key?(:icon) ? "<i class='#{item[:icon]}'></i>" : ""
            if item[:active]
              raw("#{i_tag}<strong>#{item[:name]}</strong>")
            else
              link_to(raw("#{i_tag} #{item[:name]}"), item[:link] )
            end
          end
        end
        raw(li_array.join(" "))
      end
    end
  end
end


3
4
5
# File 'app/helpers/breadcrumbs_helper.rb', line 3

def breadcrumbs_configuration
  {}
end

#configure_breadcrumbsObject



16
17
18
19
# File 'app/helpers/breadcrumbs_helper.rb', line 16

def configure_breadcrumbs
  @breadcrumbs = breadcrumbs_configuration
  @breadcrumbs.reverse_merge!(default_breadcrumbs_configuration)
end

#default_breadcrumbs_configurationObject



7
8
9
10
11
12
13
14
# File 'app/helpers/breadcrumbs_helper.rb', line 7

def default_breadcrumbs_configuration
  {
    heading: "Heading",
    description: "Description for the Page",
    links: [{name: "Home", link: "#", icon: 'fa-home'}, 
              {name: "Current Page", link: "#", icon: 'fa-calendar', active: true}]
  }
end