Class: Dry::View::Rendered

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

Overview

Output of a View rendering

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.



28
29
30
31
# File 'lib/dry/view/rendered.rb', line 28

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

Instance Attribute Details

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

Returns the hash of locals used to render the view

Returns:



25
26
27
# File 'lib/dry/view/rendered.rb', line 25

def locals
  @locals
end

#outputString (readonly)

Returns the rendered view

Returns:

  • (String)


18
19
20
# File 'lib/dry/view/rendered.rb', line 18

def output
  @output
end

Instance Method Details

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

Returns the local corresponding to the key

Parameters:

  • name (Symbol)

    local key

Returns:



40
41
42
# File 'lib/dry/view/rendered.rb', line 40

def [](name)
  locals[name]
end

#to_sString Also known as: to_str

Returns the rendered view

Returns:

  • (String)


49
50
51
# File 'lib/dry/view/rendered.rb', line 49

def to_s
  output
end