def render(thing = nil, opts = {})
opts, thing = thing, nil if thing.is_a?(Hash)
opts = self.class.default_render_options.merge(opts)
thing ||= action_name.to_sym
self.content_type = opts[:format] if opts[:format]
_handle_options!(opts)
if thing.is_a?(Symbol) || opts[:template]
template_method, template_location =
_template_for(thing, content_type, controller_name, opts[:template])
unless template_method && self.respond_to?(template_method)
template_files = Merb::Template.template_extensions.map { |ext| "#{template_location}.#{ext}" }
raise TemplateNotFound, "Oops! No template found. Merb was looking for #{template_files.join(', ')} " +
"for content type '#{content_type}'. You might have mispelled the template or file name. " +
"Registered template extensions: #{Merb::Template.template_extensions.join(', ')}. " +
"If you use Haml or some other template plugin, make sure you required Merb plugin dependency " +
"in your init file."
end
throw_content(:for_layout, self.send(template_method))
elsif thing.is_a?(String)
throw_content(:for_layout, thing)
end
(layout = _get_layout(opts[:layout])) ? send(layout) : catch_content(:for_layout)
end