# File lib/merb-core/controller/mixins/render.rb, line 317
  def _get_layout(layout = nil)
    layout = layout.instance_of?(Symbol) && self.respond_to?(layout, true) ? send(layout) : layout
    layout = layout.to_s if layout
    
    # If a layout was provided, throw an error if it's not found
    if layout
      template_method, template_location = _template_for(layout, layout.index(".") ? nil : content_type, "layout")
      raise TemplateNotFound, "No layout found at #{template_location}" unless template_method
      template_method

    # If a layout was not provided, try the default locations
    else
      template, location = _template_for(controller_name, content_type, "layout")
      template, location = _template_for("application", content_type, "layout") unless template
      template
    end
  end