Module: Really::Helpers::RenderingHelper

Defined in:
lib/really/helpers/rendering_helper.rb

Class Method Summary collapse

Class Method Details

.render_template(path, context = binding) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/really/helpers/rendering_helper.rb', line 7

def render_template(path, context = binding)
  path = File.expand_path path
  raise "File at '#{path}' is not readable. (Does it exist?)" unless File.readable?(path)

  logger.debug "Rendering eRuby template at path '#{path}'..."

  eruby = Erubis::Eruby.new File.read(path)
  result = eruby.result context

  result
end