module Roll::Amp::Helpers::Tags

Implements tags to be used in Rails templates.

Public Instance Methods

amp_analytics_js() click to toggle source

Renders script tag with link to AMP analytics JS. @return [String] HTML containing script tag.

# File lib/roll/amp/helpers/tags.rb, line 36
def amp_analytics_js
  Script::AnalyticsScriptTag.new.to_html
end
amp_boilerplate() click to toggle source

Renders AMP boilerplate stylesheet. @return [String] HTML containing style tags with boilerplate CSS.

# File lib/roll/amp/helpers/tags.rb, line 11
def amp_boilerplate
  Style::BoilerplateStyleTagsSet.new.to_html
end
amp_custom_style(file_name) click to toggle source

Renders custom stylesheet. @return [String] HTML containing style tag with content of the file specified.

# File lib/roll/amp/helpers/tags.rb, line 18
def amp_custom_style(file_name)
  Style::CustomStyleTag.new(
    Style::Stylesheet.new(
      ::Rails.root,
      ::Rails.application.assets,
      file_name
    ).read
  ).to_html
end
amp_google_analytics(account, triggers = {}) click to toggle source

Renders tags to connect Google Analytics. @return [String] HTML containing AMP analytics tag with script tag, which configures Google Analytics.

# File lib/roll/amp/helpers/tags.rb, line 43
def amp_google_analytics(account, triggers = {})
  Html::GoogleAnalyticsTag.new(
    Script::JsonScriptTag.new({
      vars: {
        account: account
      },
      triggers: triggers
    }.to_json).to_html
  ).to_html
end
amp_js() click to toggle source

Renders script tag with link to AMP main JS. @return [String] HTML containing script tag.

# File lib/roll/amp/helpers/tags.rb, line 30
def amp_js
  Script::AmpJsTag.new.to_html
end