When I render a layout while passing it a block, for example:
render(:layout => 'layouts/application') {...}
it requires the la开发者_StackOverflow中文版yout to be a partial (_application.html.erb). Is it possible to render a regular, non-partial layout without the leading underscore in its name?
Thanks!
If you pass a block to render, it is rendered as a partial as seen in the snippet below:
if block_given?
_render_partial(options.merge(:partial => options[:layout]), &block)
The full render method in Rails 3 currently looks 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
精彩评论