Sha256: c83809c3d1d7ff7847d5e5c77018f954eb26d201843ff563b0e109b29e03ab99

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

module BreadcrumbsHelper
  
  def breadcrumbs_configuration
    {}
  end

  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

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

  # Initialize @links in your controller action
  def breadcrumb
    if @breadcrumbs && @breadcrumbs.has_key?(:links) && @breadcrumbs[:links].any?
      content_tag(:div, class: "breadcrumb-env") do
        content_tag(:ol, class: "breadcrumb bc-1") do
          li_array = []
          @breadcrumbs[:links].each do |item|
            li_class = item[:active] == true ? "active" : ""
            li_array << content_tag(: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
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kuppayam-0.1.5dev2 app/helpers/breadcrumbs_helper.rb
kuppayam-0.1.5dev app/helpers/breadcrumbs_helper.rb
kuppayam-0.1.5 app/helpers/breadcrumbs_helper.rb
kuppayam-0.1.4dev app/helpers/breadcrumbs_helper.rb
kuppayam-0.1.4 app/helpers/breadcrumbs_helper.rb
kuppayam-0.1.3 app/helpers/breadcrumbs_helper.rb
kuppayam-0.1.2 app/helpers/breadcrumbs_helper.rb
kuppayam-0.1.1 app/helpers/breadcrumbs_helper.rb