Class: Breadcrumbs::Render::Inline
- Defined in:
- lib/breadcrumbs/render/inline.rb
Overview
:nodoc: all
Instance Attribute Summary
Attributes inherited from Base
#breadcrumbs, #default_options, #output_buffer
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Breadcrumbs::Render::Base
Instance Method Details
#render ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/breadcrumbs/render/inline.rb', line 6 def render = { class: "breadcrumbs", separator: "»" }.merge() html = [] items = .items size = items.size items.each_with_index do |item, i| html << render_item(item, i, size) end separator = tag(:span, [:separator], class: "separator") html.join(" #{separator} ").html_safe end |
#render_item(item, i, size) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/breadcrumbs/render/inline.rb', line 25 def render_item(item, i, size) text, url, = *item css = [[:class]].compact css << "first" if i.zero? css << "last" if i == size - 1 css << "item-#{i}" [:class] = css.join(" ") [:class].gsub!(/^ *(.*?)$/, '\\1') wrap_item(url, text, ) end |