Module: Roll::Amp::Helpers::Tags

Defined in:
lib/roll/amp/helpers/tags.rb

Overview

Implements tags to be used in Rails templates.

Instance Method Summary collapse

Instance Method Details

#amp_analytics_jsString

Renders script tag with link to AMP analytics JS.

Returns:

  • (String)

    HTML containing script tag.



36
37
38
# File 'lib/roll/amp/helpers/tags.rb', line 36

def amp_analytics_js
  Script::AnalyticsScriptTag.new.to_html
end

#amp_boilerplateString

Renders AMP boilerplate stylesheet.

Returns:

  • (String)

    HTML containing style tags with boilerplate CSS.



11
12
13
# File 'lib/roll/amp/helpers/tags.rb', line 11

def amp_boilerplate
  Style::BoilerplateStyleTagsSet.new.to_html
end

#amp_custom_style(file_name) ⇒ String

Renders custom stylesheet. content of the file specified.

Returns:

  • (String)

    HTML containing style tag with



18
19
20
21
22
23
24
25
26
# 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 = {}) ⇒ String

Renders tags to connect Google Analytics. which configures Google Analytics.

Returns:

  • (String)

    HTML containing AMP analytics tag with script tag,



43
44
45
46
47
48
49
50
51
52
# File 'lib/roll/amp/helpers/tags.rb', line 43

def amp_google_analytics(, triggers = {})
  Html::GoogleAnalyticsTag.new(
    Script::JsonScriptTag.new({
      vars: {
        account: 
      },
      triggers: triggers
    }.to_json).to_html
  ).to_html
end

#amp_jsString

Renders script tag with link to AMP main JS.

Returns:

  • (String)

    HTML containing script tag.



30
31
32
# File 'lib/roll/amp/helpers/tags.rb', line 30

def amp_js
  Script::AmpJsTag.new.to_html
end