12345678910111213141516171819202122232425262728293031323334 |
- class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
- def render
- if @elements.size > 0
- set_context
- else
- set_element
- end
- end
- def set_context
- @context.content_tag(:ol, class: 'breadcrumb') do
- @elements.collect do |element|
- render_element(element)
- end.join.html_safe
- end
- end
- def set_element
- @elements.collect do |element|
- render_element(element)
- end.join(@options[:separator] || ' »')
- end
- def render_element(element)
- current = @context.current_page?(compute_path(element))
- @context.content_tag(:li, class: "breadcrumb-item #{'active' if current}") do
- link_or_text = @context.link_to_unless_current(compute_name(element),
- compute_path(element),
- element.options)
- link_or_text
- end
- end
- end
|