class RDoc::Generator::Darkfish

def render_template template_file, out_file = nil # :yield: io

:yield: io
def render_template template_file, out_file = nil # :yield: io
  io_output = out_file && !@dry_run && @file_output
  erb_klass = io_output ? RDoc::ERBIO : ERB
  template = template_for template_file, true, erb_klass
  if io_output then
    debug_msg "Outputting to %s" % [out_file.expand_path]
    out_file.dirname.mkpath
    out_file.open 'w', 0644 do |io|
      io.set_encoding @options.encoding
      @context = yield io
      template_result template, @context, template_file
    end
  else
    @context = yield nil
    output = template_result template, @context, template_file
    debug_msg "  would have written %d characters to %s" % [
      output.length, out_file.expand_path
    ] if @dry_run
    output
  end
end