class Hanami::View::HTML::SafeString

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.

@see String#html_safe

@api public @since 2.1.0

Public Class Methods

new(string) click to toggle source

@api public @since 2.1.0

Calls superclass method
# File lib/hanami/view/html.rb, line 23
def initialize(string)
  super(string)
  freeze
end

Public Instance Methods

html_safe() click to toggle source

@return [self]

@api public @since 2.1.0

# File lib/hanami/view/html.rb, line 47
def html_safe
  self
end
html_safe?() click to toggle source

@return [true]

@api public @since 2.1.0

# File lib/hanami/view/html.rb, line 39
def html_safe?
  true
end
to_s() click to toggle source

@return [self]

@api public @since 2.1.0

# File lib/hanami/view/html.rb, line 55
def to_s
  self
end

Private Instance Methods

initialize_copy(other) click to toggle source

@api private @since 2.1.0

Calls superclass method
# File lib/hanami/view/html.rb, line 30
        def initialize_copy(other)
  super
  freeze
end