Sha256: 140a496b8eff65111b50ae5c156b1a0de84159161cd90db73a3aac3e651a22f5

Contents?: true

Size: 1.79 KB

Versions: 12

Compression:

Stored size: 1.79 KB

Contents

module ApplicationHelper
    module Amp::AmpTagHelper

        def amp_html_doctype &block
            doctype = render html: '<!doctype html>'.html_safe
            if block_given?
                html = content_tag 'html', capture(&block), ⚡: ''
            else
                html = content_tag 'html', nil, ⚡: ''
            end
            doctype + html
        end


        <% if options[:split] %>
        def amp_document_link href = request.original_url
            options = {}
            options[:href] = href
            options[:rel] = 'amphtml'
            tag "link", options
        end
        <% end %>

        def canonical_document_link href = request.original_url
            options = {}
            options[:href] = href
            options[:rel] = 'canonical'
            tag "link", options
        end


        def amp_head options = {}
            options = options.symbolize_keys

            head = render 'application/amp/head', options: options

            resources = render 'application/amp/resources'
            components = render 'application/amp/components'

            head + resources + components
        end


        def amp_resources
            warn 'AMP-HTML WARNING: `amp_resources` is deprecated and will be removed in amphtml 1.0 - use `amp_head` instead'
            resources = render 'application/amp/resources'
            components = render 'application/amp/components'
            resources + components
        end


        def amp?
            unless AmpHtml.split_view
                true
            else
                if request.format = AmpHtml.default_format
                    true
                else
                    false
                end
            end
        end

    end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
amp-html-0.7.18 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.17 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.16 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.15 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.14 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.13 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.12 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.11 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.10 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.9 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.8 lib/generators/templates/helpers/amp_tag_helper.rb.erb
amp-html-0.7.7 lib/generators/templates/helpers/amp_tag_helper.rb.erb