Class: Complate::Renderer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*context_files) ⇒ Renderer

Returns a new instance of Renderer.



9
10
11
12
13
14
# File 'lib/complate/renderer.rb', line 9

def initialize(*context_files)
  @context = V8::Context.new
  context_files.each do |file|
    @context.load(file)
  end
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



7
8
9
# File 'lib/complate/renderer.rb', line 7

def context
  @context
end

Instance Method Details

#logger=(logger) ⇒ Object



24
25
26
# File 'lib/complate/renderer.rb', line 24

def logger=(logger)
  @context['console'] = LoggerWrapper.new(logger)
end

#render(view, params = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/complate/renderer.rb', line 16

def render(view, params = {})
  Stream.new do |stream|
    # The signature is:
    # (view, params, stream, { fragment }, callback)
    @context.scope.render(view, params, stream, {})
  end
end