Module: DeepCover::Tools::RenderTemplate

Defined in:
lib/deep_cover/tools/render_template.rb

Instance Method Summary collapse

Instance Method Details

#render_template(template, bound_object) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/deep_cover/tools/render_template.rb', line 5

def render_template(template, bound_object)
  require 'erb'
  caller_path = Pathname.new(caller(1..1).first.partition(/\.rb:\d/).first).dirname
  template = caller_path.join("template/#{template}.html.erb").read
  erb = ERB.new(template)
  erb.result(bound_object.instance_eval { binding })
end