Class: BreadcrumbTrail::HTMLBuilder
- Includes:
- ActionView::Helpers
- Defined in:
- lib/breadcrumb_trail/builder.rb
Overview
Creates a structure of HTML elements to render the breadcrumbs.
Instance Method Summary collapse
-
#call ⇒ String
Renders the breadcrumbs in HTML tags.
Methods inherited from Builder
Constructor Details
This class inherits a constructor from BreadcrumbTrail::Builder
Instance Method Details
#call ⇒ String
Renders the breadcrumbs in HTML tags. If no options were provided on initialization, it uses defaults.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/breadcrumb_trail/builder.rb', line 72 def call outer_tag = @options.fetch(:outer, "ol") inner_tag = @options.fetch(:inner, "li") outer = tag(outer_tag, @options.fetch(:outer_options, nil), true) if outer_tag inner = tag(inner_tag, @options.fetch(:inner_options, nil), true) if inner_tag buffer = ActiveSupport::SafeBuffer.new buffer.safe_concat(outer) if outer_tag @breadcrumbs.each do || buffer.safe_concat(inner) if inner_tag buffer << link_to(.computed_name(@context), .computed_path(@context), .) buffer.safe_concat("</#{inner_tag}>") if inner_tag end buffer.safe_concat("</#{outer_tag}>") if outer_tag buffer end |