Class: Hanami::View::Rendered
Overview
The output of a view rendering.
Instance Attribute Summary collapse
-
#locals ⇒ Hash[<Symbol, Hanami::View::Part>] locals hash
readonly
Returns the hash of locals used to render the view output.
-
#output ⇒ String
readonly
Returns the rendered view output.
Instance Method Summary collapse
-
#[](name) ⇒ Hanami::View::Part
Returns the local corresponding to the key.
-
#include?(string) ⇒ TrueClass, FalseClass
Returns true if given string is included in the rendered view output.
-
#initialize(output:, locals:) ⇒ Rendered
constructor
private
A new instance of Rendered.
-
#match?(matcher) ⇒ TrueClass, FalseClass
(also: #match)
Returns true if the given input matches the rendered view output.
-
#to_s ⇒ String
(also: #to_str)
Returns the rendered view output.
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.
35 36 37 38 |
# File 'lib/hanami/view/rendered.rb', line 35 def initialize(output:, locals:) @output = output @locals = locals end |
Instance Attribute Details
#locals ⇒ Hash[<Symbol, Hanami::View::Part>] locals hash (readonly)
Returns the hash of locals used to render the view output.
31 32 33 |
# File 'lib/hanami/view/rendered.rb', line 31 def locals @locals end |
#output ⇒ String (readonly)
Returns the rendered view output.
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.
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.
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.
74 75 76 |
# File 'lib/hanami/view/rendered.rb', line 74 def match?(matcher) output.match?(matcher) end |
#to_s ⇒ String Also known as: to_str
Returns the rendered view output.
58 59 60 |
# File 'lib/hanami/view/rendered.rb', line 58 def to_s output end |