diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/render/partials.rb | 33 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/rendering.rb | 18 |
2 files changed, 25 insertions, 26 deletions
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 98694788f8..8e094240d3 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -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 diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index 911e480d50..0a5953be88 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -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 |