Sha256: 5ed9facdcada56b0735af5b3242ced064513c1c6f30cd6163051dea353a048a1

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 Bytes

Contents

# encoding: utf-8
module Prismic
  module Fragments
    class Embed < Fragment
      attr_accessor :embed_type, :provider, :url, :html, :o_embed_json

      def initialize(embed_type, provider, url, html, o_embed_json)
        @embed_type   = embed_type
        @provider     = provider
        @url          = url
        @html         = html
        @o_embed_json = o_embed_json
      end

      # Generate an HTML representation of the fragment
      #
      # @param link_resolver [LinkResolver] The LinkResolver used to build
      #     application's specific URL
      #
      # @return [String] the HTML representation
      def as_html(link_resolver=nil, html_serializer=nil)
        <<-HTML
        <div data-oembed="#@url"
            data-oembed-type="#{@embed_type.downcase}"
            data-oembed-provider="#{@provider.downcase}">#@html</div>
        HTML
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prismic.io-1.0.2 lib/prismic/fragments/embed.rb
prismic.io-1.0.1 lib/prismic/fragments/embed.rb