Class: Roll::Amp::Script::ScriptTag

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper
Defined in:
lib/roll/amp/script/script_tag.rb

Overview

The script tag for embedded scripts.

Direct Known Subclasses

JsonScriptTag

Instance Method Summary collapse

Constructor Details

#initialize(type, content) ⇒ ScriptTag

Initializes new instance of the script tag.

Parameters:

  • type (String)

    the MIME type of the script.

  • content (String)

    the script’s content.



14
15
16
17
# File 'lib/roll/amp/script/script_tag.rb', line 14

def initialize(type, content)
  @type = type
  @content = content
end

Instance Method Details

#to_htmlString

Prints this tag as HTML.

Returns:

  • (String)

    HTML-safe string containing the tag’s HTML view.



21
22
23
# File 'lib/roll/amp/script/script_tag.rb', line 21

def to_html
  ('script', raw(@content), type: @type)
end