render (Merb::RenderMixin)

    # File lib/merb-core/controller/mixins/render.rb, line 104
      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
        self.content_type = opts[:format] if opts[:format]

        # 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[:template])

          # Raise an error if there's no 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

          # 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 = _get_layout(opts[:layout])) ? send(layout) : catch_content(:for_layout)
      end