Load and render the erb template in the given template_file within
the specified context (a Binding
object) and write it out to outfile. Both template_file
and outfile should be Pathname-like
objects.
# File lib/rdoc/generator/darkfish.rb, line 340
def render_template( template_file, context, outfile )
template_src = template_file.read
template = ERB.new( template_src, nil, '<>' )
template.filename = template_file.to_s
output = begin
template.result( context )
rescue NoMethodError => err
raise RDoc::Error, "Error while evaluating %s: %s (at %p)" % [
template_file.to_s,
err.message,
eval( "_erbout[-50,50]", context )
], err.backtrace
end
unless $DARKFISH_DRYRUN
outfile.dirname.mkpath
outfile.open( 'w', 0644 ) do |ofh|
ofh.print( output )
end
else
debug_msg " would have written %d bytes to %s" %
[ output.length, outfile ]
end
end