mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Some more AV work:
* rename _render_partial to _render_partial_unknown_type to reflect that for this call,
we don't know the type.
* Merge _render_partial_with_block and _render_partial_with_layout to _render_partial
* TODO: Check to see if any more logic can be shared
* TODO: See about streamlining block path so we can get rid of @_proc_for_layout
* Remove @exempt_from_layout as it is no longer needed
This commit is contained in:
@@ -185,10 +185,10 @@ module ActionView
|
||||
|
||||
def render_partial(options)
|
||||
@assigns_added = false
|
||||
_render_partial(options)
|
||||
_render_partial_unknown_type(options)
|
||||
end
|
||||
|
||||
def _render_partial(options) #:nodoc:
|
||||
def _render_partial_unknown_type(options) #:nodoc:
|
||||
options[:locals] ||= {}
|
||||
|
||||
path = partial = options[:partial]
|
||||
@@ -220,19 +220,21 @@ module ActionView
|
||||
end
|
||||
end
|
||||
|
||||
def _render_partial_with_block(layout, block, options)
|
||||
@_proc_for_layout = block
|
||||
concat(_render_partial(options.merge(:partial => layout)))
|
||||
ensure
|
||||
@_proc_for_layout = nil
|
||||
end
|
||||
|
||||
def _render_partial_with_layout(layout, options)
|
||||
if layout
|
||||
prefix = layout.include?(?/) ? nil : controller_path
|
||||
layout = find_by_parts(layout, {:formats => formats}, prefix, true)
|
||||
def _render_partial(layout, options, block = nil)
|
||||
if block
|
||||
begin
|
||||
@_proc_for_layout = block
|
||||
concat(_render_partial_unknown_type(options.merge(:partial => layout)))
|
||||
ensure
|
||||
@_proc_for_layout = nil
|
||||
end
|
||||
else
|
||||
if layout
|
||||
prefix = layout.include?(?/) ? nil : controller_path
|
||||
layout = find_by_parts(layout, {:formats => formats}, prefix, true)
|
||||
end
|
||||
_render_content(_render_partial_unknown_type(options), layout, options[:locals])
|
||||
end
|
||||
_render_content(_render_partial(options), layout, options[:locals])
|
||||
end
|
||||
|
||||
def _render_partial_object(template, options)
|
||||
@@ -260,7 +262,8 @@ module ActionView
|
||||
def _render_partial_collection(collection, options = {}, passed_template = nil) #:nodoc:
|
||||
return nil if collection.blank?
|
||||
|
||||
spacer = options[:spacer_template] ? _render_partial(:partial => options[:spacer_template]) : ''
|
||||
spacer = options[:spacer_template] ?
|
||||
_render_partial_unknown_type(:partial => options[:spacer_template]) : ''
|
||||
|
||||
locals = (options[:locals] ||= {})
|
||||
index, @_partial_path = 0, nil
|
||||
|
||||
@@ -10,24 +10,22 @@ module ActionView
|
||||
#
|
||||
# If no options hash is passed or :update specified, the default is to render a partial and use the second parameter
|
||||
# as the locals hash.
|
||||
def render(options = {}, local_assigns = {}, &block) #:nodoc:
|
||||
local_assigns ||= {}
|
||||
|
||||
@exempt_from_layout = true
|
||||
|
||||
def render(options = {}, locals = {}, &block) #:nodoc:
|
||||
case options
|
||||
when String, NilClass
|
||||
_render_partial_unknown_type(:partial => options, :locals => locals || {})
|
||||
when Hash
|
||||
options[:locals] ||= {}
|
||||
layout = options[:layout]
|
||||
|
||||
return _render_partial_with_layout(layout, options) if options.key?(:partial)
|
||||
return _render_partial_with_block(layout, block, options) if block_given?
|
||||
if options.key?(:partial) || block_given?
|
||||
return _render_partial(layout, options, block)
|
||||
end
|
||||
|
||||
layout = find_by_parts(layout, {:formats => formats}) if layout
|
||||
|
||||
if file = options[:file]
|
||||
template = find_by_parts(file, {:formats => formats})
|
||||
_render_template(template, layout, :locals => options[:locals])
|
||||
_render_template(template, layout, :locals => options[:locals] || {})
|
||||
elsif inline = options[:inline]
|
||||
_render_inline(inline, layout, options)
|
||||
elsif text = options[:text]
|
||||
@@ -35,8 +33,6 @@ module ActionView
|
||||
end
|
||||
when :update
|
||||
update_page(&block)
|
||||
when String, NilClass
|
||||
_render_partial(:partial => options, :locals => local_assigns)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user