Class: Hyrax::BootstrapBreadcrumbsBuilder
- Inherits:
-
BreadcrumbsOnRails::Breadcrumbs::Builder
- Object
- BreadcrumbsOnRails::Breadcrumbs::Builder
- Hyrax::BootstrapBreadcrumbsBuilder
- Includes:
- ActionView::Helpers::OutputSafetyHelper
- Defined in:
- app/builders/hyrax/bootstrap_breadcrumbs_builder.rb
Overview
The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder. It provides basic functionalities to render a breadcrumb navigation according to Bootstrap’s conventions.
BootstrapBreadcrumbsBuilder accepts a limited set of options:
You can use it with the :builder option on render_breadcrumbs:
<%= render_breadcrumbs builder: Hyrax::BootstrapBreadcrumbsBuilder %>
Instance Method Summary collapse
Instance Method Details
#breadcrumbs_options ⇒ Object
30 31 32 |
# File 'app/builders/hyrax/bootstrap_breadcrumbs_builder.rb', line 30 def { class: 'breadcrumb', role: "navigation", "aria-label" => "Breadcrumb" } end |
#render ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/builders/hyrax/bootstrap_breadcrumbs_builder.rb', line 12 def render return "" if @elements.blank? @context.tag.nav(**) do @context.tag.ol do safe_join(@elements.uniq.collect { |e| render_element(e) }) end end end |
#render_element(element) ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/builders/hyrax/bootstrap_breadcrumbs_builder.rb', line 22 def render_element(element) html_class = 'active' if @context.current_page?(compute_path(element)) || element.["aria-current"] == "page" @context.tag.li(class: html_class) do @context.link_to_unless(html_class == 'active', @context.truncate(compute_name(element), length: 30, separator: ' '), compute_path(element), element.) end end |