Sha256: 001d52aa9eba41aefc9be8127e0adcaabc49c1b95c28e19cfa2f77a149824da4

Contents?: true

Size: 1.41 KB

Versions: 16

Compression:

Stored size: 1.41 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:
# * separator: what should be displayed as a separator between elements
#
# You can use it with the :builder option on render_breadcrumbs:
#     <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "&raquo;" %>
#
# Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
#     config.autoload_paths += Dir["#{config.root}/lib/"]
#
require 'breadcrumbs_on_rails'
class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
  def render
    @context.content_tag(:ul, class: 'breadcrumb') do
      @elements.uniq.collect do |element|
        render_element(element)
      end.join.html_safe
    end
  end

  def render_element(element)
    current = @context.current_page?(compute_path(element))

    @context.content_tag(:li, :class => ('active' if current)) do
      link_or_text = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
      divider =
      if current
        ''
      else
        @context.content_tag(:span, (@options[:separator]  || '/').html_safe, :class => 'divider')
      end

      link_or_text + divider
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
curate-0.6.6 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.6.5 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.6.4 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.6.3 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.6.1 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.6.0 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.5.6 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.5.5 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.5.4 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.5.2 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.5.1 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.5.0 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.4.2 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.3.2 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.3.1 app/builders/bootstrap_breadcrumbs_builder.rb
curate-0.2.0 app/builders/bootstrap_breadcrumbs_builder.rb