Class: MVCLI::Renderer

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

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Renderer

Returns a new instance of Renderer.



5
6
7
# File 'lib/mvcli/renderer.rb', line 5

def initialize(root)
  @root = root
end

Instance Method Details

#render(output, path, context) ⇒ Object



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

def render(output, path, context)
  filename = @root.join('app/views', path + '.txt.erb').to_s
  compiler = MVCLI::ERB.new
  template = compiler.compile File.read(filename), filename
  template.call(context, output)
end