Class: Hanami::View::HTML::SafeString
- Defined in:
- lib/hanami/view/html.rb
Overview
A string that has been marked as “HTML safe”, ensuring that it is not automatically escaped when used in HTML view templates.
A SafeString is frozen when initialized to ensure it cannot be mutated after being marked as safe, which could be an avenue for injection of unsafe content.
Instance Method Summary collapse
- #html_safe ⇒ self
- #html_safe? ⇒ true
-
#initialize(string) ⇒ SafeString
constructor
A new instance of SafeString.
- #to_s ⇒ self
Constructor Details
#initialize(string) ⇒ SafeString
Returns a new instance of SafeString.
23 24 25 26 |
# File 'lib/hanami/view/html.rb', line 23 def initialize(string) super(string) freeze end |
Instance Method Details
#html_safe ⇒ self
47 48 49 |
# File 'lib/hanami/view/html.rb', line 47 def html_safe self end |
#html_safe? ⇒ true
39 40 41 |
# File 'lib/hanami/view/html.rb', line 39 def html_safe? true end |
#to_s ⇒ self
55 56 57 |
# File 'lib/hanami/view/html.rb', line 55 def to_s self end |