From 216309c16519d94a9e0aebf758029a78696ab8d6 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Tue, 12 May 2009 16:21:34 -0700 Subject: Implemented redirects and partial rendering in new base. --- actionpack/lib/action_view/render/partials.rb | 32 ++++++++++++++++---------- actionpack/lib/action_view/render/rendering.rb | 5 ++++ 2 files changed, 25 insertions(+), 12 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 43f8a1edf8..f2429e8cef 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -171,11 +171,21 @@ module ActionView # <% end %> module Partials extend ActiveSupport::Memoizable + extend ActiveSupport::DependencyModule + + included do + attr_accessor :_partial + end + + def _render_partial_from_controller(*args) + @assigns_added = false + _render_partial(*args) + end def _render_partial(options = {}) #:nodoc: options[:locals] ||= {} - case path = partial = options[:partial] + case path = partial = options[:partial] when *_array_like_objects return _render_partial_collection(partial, options) else @@ -222,16 +232,7 @@ module ActionView ensure @_proc_for_layout = nil end - - def _render_partial_with_layout(layout, options) - if layout - prefix = controller && !layout.include?("/") ? controller.controller_path : nil - layout = find_by_parts(layout, {:formats => formats}, prefix, true) - end - content = _render_partial(options) - return _render_content_with_layout(content, layout, options[:locals]) - end - + def _deprecated_ivar_assign(template) if respond_to?(:controller) ivar = :"@#{template.variable_name}" @@ -287,13 +288,17 @@ module ActionView locals = (options[:locals] ||= {}) object ||= locals[:object] || locals[template.variable_name] - _set_locals(object, locals, template, options) + _set_locals(object, locals, template, options) + + self._partial = template + _render_template(template, locals) end end def _set_locals(object, locals, template, options) object ||= _deprecated_ivar_assign(template) + locals[:object] = locals[template.variable_name] = object locals[options[:as]] = object if options[:as] end @@ -316,6 +321,9 @@ module ActionView locals[template.counter_name] = index index += 1 + + self._partial = template + _render_template(template, locals) end.join(spacer) end diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index 6e368f27eb..fe785e7b20 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -95,6 +95,11 @@ module ActionView layout ? _render_content_with_layout(text, layout, options[:locals]) : text end + def _render_template_from_controller(*args) + @assigns_added = nil + _render_template_with_layout(*args) + end + def _render_template_with_layout(template, layout = nil, options = {}, partial = false) if controller && logger logger.info("Rendering #{template.identifier}" + -- cgit v1.2.3