Sha256: 2a09ecc3fcf3d3c753adc3940797cc562659f2fb3e48434bd529e5499c87bfa3

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

class Breadcrumbs
  module Render
    class List < Base # :nodoc: all
      def render
        options = {
          :class => "breadcrumbs"
        }.merge(default_options)

        tag(list_style, options) do
          html = ""
          items = breadcrumbs.items
          size = items.size

          items.each_with_index do |item, i|
            html << render_item(item, i, size)
          end

          html
        end
      end

      def list_style
        :ul
      end

      def render_item(item, i, size)
        css = []
        css << "first" if i == 0
        css << "last" if i == size - 1
        css << "item-#{i}"

        text, url, options = *item
        text = wrap_item(url, CGI.escapeHTML(text), options)
        tag(:li, text, :class => css.join(" "))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
breadcrumbs-0.1.6 lib/breadcrumbs/render/list.rb
breadcrumbs-0.1.5 lib/breadcrumbs/render/list.rb