Sha256: b0a57af161c51b7f2706f0fc6ec20875e4f7ea708c27b9c17077a67bc99c1343

Contents?: true

Size: 1.28 KB

Versions: 12

Compression:

Stored size: 1.28 KB

Contents

module BreadcrumbsHelper
  def breadcrumbs(e, extra=nil)
    breadcrumbs0(e.navigable_name, e, extra, 'last')
  end

  def header_breadcrumbs(link_for_organization: true)
    "#{home_breadcrumb} #{organization_breadcrumb(has_link: link_for_organization)}".html_safe
  end

  def home_breadcrumb
    home = "<i class='da da-mumuki' aria-label=#{t(:home)}></i>".html_safe
    breadcrumb_item_for_linkable home, mu_home_path, 'brand'
  end

  def mu_home_path
    root_path
  end

  def breadcrumb_item_class(clazz)
    "class='mu-breadcrumb-list-item #{clazz}'"
  end

  def breadcrumb_list_item(item, clazz='')
    "<li #{breadcrumb_item_class(clazz)}>#{h item}</li>".html_safe
  end

  def breadcrumb_item_for_linkable(e, link_path, clazz='')
    breadcrumb_list_item link_to(e, link_path), clazz
  end

  private

  def breadcrumbs_for_linkable(e, extra=nil, last='')
    breadcrumbs0(link_to_path_element(e), e, extra, last)
  end

  def breadcrumbs0(base, e, extra, last)
    return "#{breadcrumbs_for_linkable(e)} #{breadcrumb_list_item(extra, last)}".html_safe if extra

    if e.navigation_end?
      "#{header_breadcrumbs} #{breadcrumb_list_item(base, last)}".html_safe
    else
      "#{breadcrumbs_for_linkable(e.navigable_parent)} #{breadcrumb_list_item(base, last)}".html_safe
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mumuki-laboratory-7.3.1 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.3.0 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.2.0 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.1.0 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.12 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.11 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.10 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.9 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.8 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.7 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.6 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.5 app/helpers/breadcrumbs_helper.rb