Sha256: e92dcc10c02ef74636637b72105681c432ac83a7d3f6002096a6cbc3b0c2a1db

Contents?: true

Size: 974 Bytes

Versions: 1

Compression:

Stored size: 974 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')

        if url
          text = tag(:a, text, options.merge(:href => url))
        else
          text = tag(:span, text, options)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breadcrumbs-0.1.0 lib/breadcrumbs/render/inline.rb