Class: Pakada::Render::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/pakada/render/renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine, locals = {}) ⇒ Renderer

Returns a new instance of Renderer.



5
6
7
8
# File 'lib/pakada/render/renderer.rb', line 5

def initialize(engine, locals = {})
  @engine, @locals = engine, locals
  @instance = Pakada.instance
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



3
4
5
# File 'lib/pakada/render/renderer.rb', line 3

def engine
  @engine
end

#localsObject (readonly)

Returns the value of attribute locals.



3
4
5
# File 'lib/pakada/render/renderer.rb', line 3

def locals
  @locals
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/pakada/render/renderer.rb', line 21

def [](key)
 locals[key]
end

#[]=(key, value) ⇒ Object



25
26
27
# File 'lib/pakada/render/renderer.rb', line 25

def []=(key, value)
  locals[key] = value
end

#each {|to_s| ... } ⇒ Object

Yields:



17
18
19
# File 'lib/pakada/render/renderer.rb', line 17

def each
  yield to_s
end

#to_sObject



10
11
12
13
14
15
# File 'lib/pakada/render/renderer.rb', line 10

def to_s
  @string ||= Pakada.instance(@instance.name) {
    context = Pakada.safety(Pakada::Render::RenderingContext).new
    engine.render context, locals
  }
end