class Hanami::View::Rendered

The output of a view rendering.

@api public @since 2.1.0

Attributes

locals[R]

Returns the hash of locals used to render the view output.

@return [Hash[<Symbol, Hanami::View::Part>] locals hash

@api public @since 2.1.0

output[R]

Returns the rendered view output.

@return [String]

@see to_s @see to_str

@api public @since 2.1.0

Public Class Methods

new(output:, locals:) click to toggle source

@api private @since 2.1.0

# File lib/hanami/view/rendered.rb, line 35
def initialize(output:, locals:)
  @output = output
  @locals = locals
end

Public Instance Methods

[](name) click to toggle source

Returns the local corresponding to the key.

@param name [Symbol] local key

@return [Hanami::View::Part]

@api public @since 2.1.0

# File lib/hanami/view/rendered.rb, line 48
def [](name)
  locals[name]
end
include?(string) click to toggle source

Returns true if given string is included in the rendered view output.

@param string [String] string

@return [TrueClass,FalseClass]

@api public @since 2.1.0

# File lib/hanami/view/rendered.rb, line 87
def include?(string)
  output.include?(string)
end
match(matcher)
Alias for: match?
match?(matcher) click to toggle source

Returns true if the given input matches the rendered view output.

@param matcher [String, Regexp] matcher

@return [TrueClass,FalseClass]

@api public @since 2.1.0

# File lib/hanami/view/rendered.rb, line 74
def match?(matcher)
  output.match?(matcher)
end
Also aliased as: match
to_s() click to toggle source

Returns the rendered view output.

@return [String]

@api public @since 2.1.0

# File lib/hanami/view/rendered.rb, line 58
def to_s
  output
end
Also aliased as: to_str
to_str()

@api public @since 2.1.0

Alias for: to_s