Sha256: cb8b94c9f9f2e7105759aed2ef4b614f596e915b4e4d17b12cad5ecd02c5000a

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

class Breadcrumbs
  module Render
    class Bootstrap < List # :nodoc: all

      attr_reader :separator

      # @overload
      def initialize(*)
        super
        @separator = options.delete(:separator)
      end

      # @overload
      def default_options
        super.merge(:class => "breadcrumb", :separator => "/")
      end

      # @overload
      def render_item(item, i, size)
        html_opts, suffix = {},  nil
        if i == size - 1
          html_opts.update :class => "active"
        elsif separator
          suffix = tag(:span, separator, :class => "divider")
        end

        text, url, options = *item
        text = [escape(text), suffix].join
        text = wrap_item(url, text, options)
        tag(:li, text, html_opts)
      end

      protected

      # @overload
      def wrap_item(url, text, *)
        url ? tag(:a, text, :href => url) : text
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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