Class: Breadcrumbs::Render::List
- Inherits:
-
Base
- Object
- Base
- Breadcrumbs::Render::List
- Defined in:
- lib/breadcrumbs/render/list.rb
Overview
:nodoc: all
Instance Method Summary collapse
Instance Method Details
#list_style ⇒ Object
21 22 23 |
# File 'lib/breadcrumbs/render/list.rb', line 21 def list_style :ul end |
#render ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/breadcrumbs/render/list.rb', line 4 def render = {:class => "breadcrumb", :separator => "/"}.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 end end |
#render_item(item, i, size, opts) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/breadcrumbs/render/list.rb', line 25 def render_item(item, i, size, opts) css = "active" if i == size - 1 length = .items.length - 1 text, url, = *item # If the item is the last, doesn't wrap with <a> if i < length text = wrap_item(url, CGI.escapeHTML(text), ) else text = CGI.escapeHTML text end # If the item is not last, add divider if i < length text += tag(:span, opts[:separator], :class => "divider") end tag(:li, text, :class => css) end |