# File lib/merb-core/controller/mixins/render.rb, line 83
  def render(thing = nil, opts = {})
    # render :format => :xml means render nil, :format => :xml
    opts, thing = thing, nil if thing.is_a?(Hash)
    
    # Merge with class level default render options
    opts = self.class.default_render_options.merge(opts)
    
    # If you don't specify a thing to render, assume they want to render the current action
    thing ||= action_name.to_sym

    # Content negotiation
    opts[:format] ? (self.content_type = opts[:format]) : content_type 
    
    # Handle options (:status)
    _handle_options!(opts)    
    
    # Do we have a template to try to render?
    if thing.is_a?(Symbol) || opts[:template]

      template_method, template_location = _template_for(thing, content_type, controller_name, opts)
  
      # Raise an error if there's no template
      raise TemplateNotFound, "No template found at #{template_location}.*"  \
        unless template_method && self.respond_to?(template_method)

      # Call the method in question and throw the content for later consumption by the layout
      throw_content(:for_layout, self.send(template_method))
      
    # Do we have a string to render?
    elsif thing.is_a?(String)
      
      # Throw it for later consumption by the layout
      throw_content(:for_layout, thing)
    end
    
    # If we find a layout, use it. Otherwise, just render the content thrown for layout.
    layout = opts[:layout] != false && _get_layout(opts[:layout])
    layout ? send(layout) : catch_content(:for_layout)
  end