Sha256: 5d182aca87705ff6c930ddcbef067a22774e39a1ef934c402a4f13622a0acb54

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

class Breadcrumbs
  module Render
    class Inline < Base # :nodoc: all
      def render
        options = {:class => "breadcrumbs", :separator => "&#187;"}.merge(default_options)

        html = []
        items = breadcrumbs.items
        size = items.size

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

        separator = tag(:span, options[:separator], :class => "separator")

        html.join(" #{separator} ")
      end

      def render_item(item, i, size)
        text, url, options = *item
        options[:class] ||= ""

        css = []
        css << "first" if i == 0
        css << "last" if i == size - 1
        css << "item-#{i}"

        options[:class] << " #{css.join(" ")}"
        options[:class].gsub!(/^ *(.*?)$/, '\\1')

        wrap_item(url, CGI.escapeHTML(text), options)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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