class Roll::Amp::Script::IncludeScriptTag

The script tag to include AMP scripts. Note, it's always async.

Public Class Methods

new(src, custom_element = '') click to toggle source

Initializes new instance of the include script tag. @param src [String] the URL to the script. @param custom_element [String] the custom-element attribute value.

# File lib/roll/amp/script/include_script_tag.rb, line 13
def initialize(src, custom_element = '')
  @src = src
  @custom_element = custom_element
end

Public Instance Methods

to_html() click to toggle source

Prints this tag as HTML. @return [String] HTML-safe string containing the tag's HTML view.

# File lib/roll/amp/script/include_script_tag.rb, line 20
def to_html
  if @custom_element.empty?
    raw("<script async src=\"#{@src}\"></script>")
  else
    raw(
      "<script async src=\"#{@src}\" " \
      "custom-element=\"#{@custom_element}\"></script>"
    )
  end
end