Sha256: 8b1f0bf3f06edade55df9ae8c37daaaa208267beab3de8e1fd2a252a3d4d0b09

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

module StructuredData
  module RailsExtentions
    def self.included(controller)
      controller.helper_method :repository
      controller.helper_method :display_structured_data

      controller.include StructuredData::RailsExtentions::BreadclumbList
      controller.include StructuredData::RailsExtentions::SiteNavigationElement
    end

    def repository
      @structured_data_repository ||= StructuredData::Repository.new
    end

    def display_structured_data
      repository << breadcrumb_list unless breadcrumb_list.empty?
      repository << site_navigation_element unless site_navigation_element.empty?

      view_context.content_tag(:script, repository.dump.html_safe, type: 'application/ld+json')
    end
  end
end

require 'structured_data/rails_extentions/breadcrumb_list'
require 'structured_data/rails_extentions/site_navigation_element'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
structured-data-0.2.1 lib/structured_data/rails_extentions.rb
structured-data-0.2.0 lib/structured_data/rails_extentions.rb