module Sinatra::Templates
def render(engine, data, options={}, locals={}, &block)
def render(engine, data, options={}, locals={}, &block) # merge app-level options options = settings.send(engine).merge(options) if settings.respond_to?(engine) options[:outvar] ||= '@_out_buf' # extract generic options locals = options.delete(:locals) || locals || {} views = options.delete(:views) || settings.views || "./views" @default_layout = :layout if @default_layout.nil? layout = options.delete(:layout) layout = @default_layout if layout.nil? or layout == true content_type = options.delete(:content_type) || options.delete(:default_content_type) # compile and render template layout_was = @default_layout @default_layout = false if layout template = compile_template(engine, data, options, views) output = template.render(self, locals, &block) @default_layout = layout_was # render layout if layout begin options = options.merge(:views => views, :layout => false) output = render(engine, layout, options, locals) { output } rescue Errno::ENOENT end end output.extend(ContentTyped).content_type = content_type if content_type output end