module Roda::RodaPlugins::Render

def self.configure(app, opts=OPTS)

Setup default rendering options. See Render for details.
def self.configure(app, opts=OPTS)
  if app.opts[:render]
    opts = app.opts[:render][:orig_opts].merge(opts)
  end
  app.opts[:render] = opts.dup
  app.opts[:render][:orig_opts] = opts
  opts = app.opts[:render]
  opts[:engine] = (opts[:engine] || opts[:ext] || "erb").dup.freeze
  opts[:views] = File.expand_path(opts[:views]||"views", app.opts[:root]).freeze
  if opts.fetch(:cache, ENV['RACK_ENV'] != 'development')
    if cache_class = opts[:cache_class]
      opts[:cache] = cache_class.new
    else
      opts[:cache] = app.thread_safe_cache
    end
  end
  opts[:layout_opts] = (opts[:layout_opts] || {}).dup
  opts[:layout_opts][:_is_layout] = true
  if layout = opts.fetch(:layout, true)
    opts[:layout] = true unless opts.has_key?(:layout)
    case layout
    when Hash
      opts[:layout_opts].merge!(layout)
    when true
      opts[:layout_opts][:template] ||= 'layout'
    else
      opts[:layout_opts][:template] = layout
    end
  end
  opts[:layout_opts].freeze
  template_opts = opts[:template_opts] = (opts[:template_opts] || {}).dup
  template_opts[:outvar] ||= '@_out_buf'
  if RUBY_VERSION >= "1.9" && !template_opts.has_key?(:default_encoding)
    template_opts[:default_encoding] = Encoding.default_external
  end
  if opts[:escape]
    template_opts[:engine_class] = ErubisEscaping::Eruby
    opts[:escaper] ||= if opts[:escape_safe_classes]
      ErubisEscaping::UnsafeClassEscaper.new(opts[:escape_safe_classes])
    else
      ::Erubis::XmlHelper
    end
  end
  template_opts.freeze
  engine_opts = opts[:engine_opts] = (opts[:engine_opts] || {}).dup
  engine_opts.to_a.each do |k,v|
    engine_opts[k] = v.dup.freeze
  end
  engine_opts.freeze
  opts.freeze
end

def self.load_dependencies(app, opts=OPTS)

def self.load_dependencies(app, opts=OPTS)
  if opts[:escape]
    app.plugin :_erubis_escaping
  end
end