Sha256: 8a53edbaea260e10194b6908fd7d354e183587758ddf3d6f0e685b3f5b9e5c83

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 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

1 entries across 1 versions & 1 rubygems

Version Path
breadcrumbs-0.1.7 lib/breadcrumbs/render/list.rb