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. --- .../lib/action_controller/new_base/renderer.rb | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_controller/new_base/renderer.rb') diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb index 41e3dfbe23..8a9f230603 100644 --- a/actionpack/lib/action_controller/new_base/renderer.rb +++ b/actionpack/lib/action_controller/new_base/renderer.rb @@ -9,13 +9,9 @@ module ActionController super end - def render(options = {}) + def render_to_body(options) _process_options(options) - super(options) - end - - def render_to_body(options) if options.key?(:text) options[:_template] = ActionView::TextTemplate.new(_text(options)) template = nil @@ -25,12 +21,18 @@ module ActionController options[:_template] = template elsif options.key?(:template) options[:_template_name] = options[:template] + elsif options.key?(:file) + options[:_template_name] = options[:file] + elsif options.key?(:partial) + _render_partial(options[:partial], options) else options[:_template_name] = (options[:action] || action_name).to_s options[:_prefix] = _prefix end ret = super(options) + + options[:_template] ||= _action_view._partial response.content_type ||= options[:_template].mime_type ret end @@ -49,6 +51,21 @@ module ActionController else text.to_s end end + + def _render_partial(partial, options) + case partial + when true + options[:_prefix] = _prefix + when String + options[:_prefix] = _prefix unless partial.index('/') + options[:_template_name] = partial + else + options[:_partial_object] = true + return + end + + options[:_partial] = options[:object] || true + end def _process_options(options) status, content_type = options.values_at(:status, :content_type) -- cgit v1.2.3