Sha256: c6ef8832ea1326dab19c628136f8b7f656fcdf30c624c1f89785a5bbf37d5491

Contents?: true

Size: 779 Bytes

Versions: 5

Compression:

Stored size: 779 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 = ""
          size = breadcrumbs.size

          breadcrumbs.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, escape(text), options)
        tag(:li, text, :class => css.join(" "))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bsm-breadcrumbs-0.3.3 lib/breadcrumbs/render/list.rb
bsm-breadcrumbs-0.3.2 lib/breadcrumbs/render/list.rb
bsm-breadcrumbs-0.3.1 lib/breadcrumbs/render/list.rb
bsm-breadcrumbs-0.3.0 lib/breadcrumbs/render/list.rb
bsm-breadcrumbs-0.2.1 lib/breadcrumbs/render/list.rb