Sha256: dab5bd5a5cc0194ce3fe350b9931660cc0ad465c220dbd80aa856d393d2af486

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

# 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 => Spotlight::BootstrapBreadcrumbsBuilder %>
#
class Spotlight::BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
  include ActionView::Helpers::OutputSafetyHelper
  def render
    if @elements.blank?
      return ""
    end

    @context.content_tag(:ul, class: 'breadcrumb') do
      safe_join(@elements.uniq.collect {|e| render_element(e)})
    end 
  end

  def render_element(element)
    html_class = 'active' if @context.current_page?(compute_path(element))

    @context.content_tag(:li, :class => html_class) do
      @context.link_to_unless_current(@context.truncate(compute_name(element), length: 30, separator: ' '), compute_path(element), element.options)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-spotlight-0.4.1 app/builders/spotlight/bootstrap_breadcrumbs_builder.rb
blacklight-spotlight-0.3.1 app/builders/spotlight/bootstrap_breadcrumbs_builder.rb
blacklight-spotlight-0.3.0 app/builders/spotlight/bootstrap_breadcrumbs_builder.rb
blacklight-spotlight-0.2.0 app/builders/spotlight/bootstrap_breadcrumbs_builder.rb
blacklight-spotlight-0.1.0 app/builders/spotlight/bootstrap_breadcrumbs_builder.rb