Class: Hanami::View::Rendered

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/view/rendered.rb

Overview

The output of a view rendering.

Since:

  • 2.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output:, locals:) ⇒ Rendered

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Rendered.

Since:

  • 2.1.0



35
36
37
38
# File 'lib/hanami/view/rendered.rb', line 35

def initialize(output:, locals:)
  @output = output
  @locals = locals
end

Instance Attribute Details

#localsHash[<Symbol, Hanami::View::Part>] locals hash (readonly)

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

Returns:

Since:

  • 2.1.0



31
32
33
# File 'lib/hanami/view/rendered.rb', line 31

def locals
  @locals
end

#outputString (readonly)

Returns the rendered view output.

Returns:

See Also:

Since:

  • 2.1.0



23
24
25
# File 'lib/hanami/view/rendered.rb', line 23

def output
  @output
end

Instance Method Details

#[](name) ⇒ Hanami::View::Part

Returns the local corresponding to the key.

Parameters:

  • name (Symbol)

    local key

Returns:

Since:

  • 2.1.0



48
49
50
# File 'lib/hanami/view/rendered.rb', line 48

def [](name)
  locals[name]
end

#include?(string) ⇒ TrueClass, FalseClass

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

Parameters:

Returns:

  • (TrueClass, FalseClass)

Since:

  • 2.1.0



87
88
89
# File 'lib/hanami/view/rendered.rb', line 87

def include?(string)
  output.include?(string)
end

#match?(matcher) ⇒ TrueClass, FalseClass Also known as: match

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

Parameters:

  • matcher (String, Regexp)

    matcher

Returns:

  • (TrueClass, FalseClass)

Since:

  • 2.1.0



74
75
76
# File 'lib/hanami/view/rendered.rb', line 74

def match?(matcher)
  output.match?(matcher)
end

#to_sString Also known as: to_str

Returns the rendered view output.

Returns:

Since:

  • 2.1.0



58
59
60
# File 'lib/hanami/view/rendered.rb', line 58

def to_s
  output
end