Sha256: 89617d5d8090300c60d4dd5f6bdfd026f18cae016cc96a29ebcc0c62588425ff

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# The MicrodataBuilder is like the default breadcrumb builder.
# but it allows to inject microdata semantics in the HTML code.
# cf. http://www.data-vocabulary.org/Breadcrumb/
#
# You have to put this in your environment :
#     require 'breadcrumbs_on_rails/breadcrumbs/microdata_builder'
# then configure your renderer, like this :
#     <%= render_breadcrumbs(
#           :builder => BreadcrumbsOnRailsMicrodataBuilder::Breadcrumbs::MicrodataBuilder,
#         ).html_safe %>
#
module BreadcrumbsOnRailsMicrodataBuilder
  module Breadcrumbs
    class MicrodataBuilder < Builder
      def render
        @elements.collect do |element|
          render_element(element)
        end.join(@options[:separator] || " &raquo; ")
      end

      def render_element(element)
        url = (compute_path(element).present? ? compute_path(element) : '#')
        subcontent = @context.content_tag(:span, compute_name(element), :itemprop => 'title')
        content = @context.link_to_unless_current(subcontent, url, :itemprop => 'url')
        @context.content_tag(:span, content, :itemscope => "", :itemtype => "http://data-vocabulary.org/Breadcrumb")
      end  
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breadcrumbs_on_rails_microdata_builder-2.2.3 lib/breadcrumbs_on_rails_microdata_builder/breadcrumbs/microdata_builder.rb