Class: Breadcrumbs::Render::List
- Defined in:
- lib/breadcrumbs/render/list.rb
Overview
:nodoc: all
Direct Known Subclasses
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
#list_style ⇒ Object
22 23 24 |
# File 'lib/breadcrumbs/render/list.rb', line 22 def list_style :ul end |
#render ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/breadcrumbs/render/list.rb', line 6 def render = {class: "breadcrumbs"}.merge() tag(list_style, ) do html = [] items = .items size = items.size items.each_with_index do |item, i| html << render_item(item, i, size) end html.join.html_safe end end |
#render_item(item, i, size) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/breadcrumbs/render/list.rb', line 26 def render_item(item, i, size) css = [] css << "first" if i.zero? css << "last" if i == size - 1 css << "item-#{i}" text, url, = *item text = wrap_item(url, text, ) tag(:li, text, class: css.join(" ")) end |