Sha256: 2429224511dd7037ea8ec39bff7c338286723b8705dbd455947c9bc33c8a570d

Contents?: true

Size: 855 Bytes

Versions: 5

Compression:

Stored size: 855 Bytes

Contents

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

        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

5 entries across 5 versions & 1 rubygems

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