How to visualize a non-partial layout by passing a block to it?

When I create a layout by passing a block to it, for example:

render(:layout => 'layouts/application') {...}

this requires the layout to be partial (_application.html.erb). Is it possible to make a regular, non-partial layout without a leading underscore in her name?

Thank!

+5
source share
1 answer

If you pass a block for rendering, it is displayed as partial, as shown in the snippet below:

if block_given?
      _render_partial(options.merge(:partial => options[:layout]), &block)

Now the full rendering method in Rails 3 is as follows:

def render(options = {}, locals = {}, &block)
  case options
  when Hash
    if block_given?
      _render_partial(options.merge(:partial => options[:layout]), &block)
    elsif options.key?(:partial)
      _render_partial(options)
    else
      template = _determine_template(options)
      lookup_context.freeze_formats(template.formats, true)
      _render_template(template, options[:layout], options)
    end
  when :update
    update_page(&block)
  else
    _render_partial(:partial => options, :locals => locals)
  end
end
+1
source

All Articles