Class: BreadcrumbsOnRails::Breadcrumbs::SimpleBuilder

Inherits:
Builder
  • Object
show all
Defined in:
lib/breadcrumbs_on_rails/breadcrumbs.rb

Overview

The SimpleBuilder is the default breadcrumb builder. It provides basic functionalities to render a breadcrumb navigation.

The SimpleBuilder accepts a limited set of options. If you need more flexibility, create a custom Builder and pass the option :builder => BuilderClass to the render_breadcrumbs helper method.

Instance Method Summary collapse

Methods inherited from Builder

#initialize

Constructor Details

This class inherits a constructor from BreadcrumbsOnRails::Breadcrumbs::Builder

Instance Method Details

#renderObject



81
82
83
84
85
# File 'lib/breadcrumbs_on_rails/breadcrumbs.rb', line 81

def render
  @elements.collect do |element|
    render_element(element)
  end.join(@options[:separator] || " » ")
end

#render_element(element) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/breadcrumbs_on_rails/breadcrumbs.rb', line 87

def render_element(element)
  if element.path == nil
    content = compute_name(element)
  else
    content = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
  end
  if @options[:tag]
    @context.(@options[:tag], content)
  else
    ERB::Util.h(content)
  end
end