module ActionView::Layouts
def _conditional_layout?
def _conditional_layout? true end
def _default_layout(formats, require_layout = false)
==== Returns
an +ArgumentError+ exception is raised (defaults to +false+)
* require_layout - If set to +true+ and layout is not found,
* formats - The formats accepted to this layout
==== Parameters
Optionally raises an exception if the layout could not be found.
Returns the default layout for this controller.
def _default_layout(formats, require_layout = false) begin value = _layout(formats) if action_has_layout? rescue NameError => e raise e, "Could not render layout: #{e.message}" end if require_layout && action_has_layout? && !value raise ArgumentError, "There was no default layout for #{self.class} in #{view_paths.inspect}" end _normalize_layout(value) end
def _include_layout?(options)
def _include_layout?(options) (options.keys & [:body, :plain, :html, :inline, :partial]).empty? || options.key?(:layout) end
def _layout(*); end
def _layout(*); end
def _layout_for_option(name)
==== Parameters
Determine the layout for a given name, taking into account the name type.
def _layout_for_option(name) case name when String then _normalize_layout(name) when Proc then name when true then Proc.new { |formats| _default_layout(formats, true) } when :default then Proc.new { |formats| _default_layout(formats, false) } when false, nil then nil else raise ArgumentError, "String, Proc, :default, true, or false, expected for `layout'; you passed #{name.inspect}" end end
def _normalize_layout(value)
def _normalize_layout(value) value.is_a?(String) && value !~ /\blayouts/ ? "layouts/#{value}" : value end
def _normalize_options(options) # :nodoc:
def _normalize_options(options) # :nodoc: super if _include_layout?(options) layout = options.delete(:layout) { :default } options[:layout] = _layout_for_option(layout) end end
def action_has_layout?
for that action or set the action_has_layout attribute
either override this method in your controller to return false
current action so that it is rendered without a layout then
If you want to disable any layout settings for the
Controls whether an action should be rendered using a layout.
def action_has_layout? @_action_has_layout end
def initialize(*) # :nodoc:
def initialize(*) # :nodoc: @_action_has_layout = true super end