Sha256: 0946c49dc600b5ffe6201a7772b30cd3f8bf9c9cb72df87839963bb597a53c2f

Contents?: true

Size: 881 Bytes

Versions: 4

Compression:

Stored size: 881 Bytes

Contents

class Breadcrumbs
  module Render
    class Inline < Base # :nodoc: all

      # @overload
      def default_options
        super.merge(:separator => "&#187;")
      end

      # @overload
      def render
        html = []
        size = breadcrumbs.size

        breadcrumbs.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, escape(text), options)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bsm-breadcrumbs-0.5.2 lib/breadcrumbs/render/inline.rb
bsm-breadcrumbs-0.5.1 lib/breadcrumbs/render/inline.rb
bsm-breadcrumbs-0.5.0 lib/breadcrumbs/render/inline.rb
bsm-breadcrumbs-0.4.0 lib/breadcrumbs/render/inline.rb