Class: Roll::Amp::Script::IncludeScriptTag
- Inherits:
-
Object
- Object
- Roll::Amp::Script::IncludeScriptTag
- Includes:
- ActionView::Helpers::OutputSafetyHelper
- Defined in:
- lib/roll/amp/script/include_script_tag.rb
Overview
The script tag to include AMP scripts. Note, it’s always async.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(src, custom_element = '') ⇒ IncludeScriptTag
constructor
Initializes new instance of the include script tag.
-
#to_html ⇒ String
Prints this tag as HTML.
Constructor Details
#initialize(src, custom_element = '') ⇒ IncludeScriptTag
Initializes new instance of the include script tag.
13 14 15 16 |
# File 'lib/roll/amp/script/include_script_tag.rb', line 13 def initialize(src, custom_element = '') @src = src @custom_element = custom_element end |
Instance Method Details
#to_html ⇒ String
Prints this tag as HTML.
20 21 22 23 24 25 26 27 28 29 |
# 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 |