diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/abstract/renderer.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_controller/new_base/renderer.rb | 52 |
2 files changed, 44 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb index 537335aa0e..19a64b0c38 100644 --- a/actionpack/lib/action_controller/abstract/renderer.rb +++ b/actionpack/lib/action_controller/abstract/renderer.rb @@ -25,8 +25,8 @@ module AbstractController self.response_body = render_to_string(template) end - def render_to_string(template = action_name) - tmp = view_paths.find_by_parts(template.to_s, formats, _prefix) + def render_to_string(template = action_name, prefix = true) + tmp = view_paths.find_by_parts(template.to_s, formats, (_prefix if prefix)) _render_template(tmp) end diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb index eb3c8b808d..540924936d 100644 --- a/actionpack/lib/action_controller/new_base/renderer.rb +++ b/actionpack/lib/action_controller/new_base/renderer.rb @@ -1,7 +1,24 @@ module ActionController module Renderer - def render(options) + # def self.included(klass) + # klass.extend ClassMethods + # end + # + # module ClassMethods + # def prefix + # @prefix ||= name.underscore + # end + # end + + def render(action, options = {}) + # TODO: Move this into #render_to_string + if action.is_a?(Hash) + options, action = action, nil + else + options.merge! :action => action + end + _process_options(options) self.response_body = render_to_string(options) @@ -9,22 +26,37 @@ module ActionController def render_to_string(options) self.formats = [:html] + + unless options.is_a?(Hash) + options = {:action => options} + end if options.key?(:text) - text = options.delete(:text) - - case text - when nil then " " - else text.to_s - end + _render_text(options) elsif options.key?(:template) - template = options.delete(:template) - + template = options.delete(:template) + super(template, false) + elsif options.key?(:action) + template = options.delete(:action).to_s super(template) end end - private + private + + def _prefix + controller_path + end + + def _render_text(options) + text = options.delete(:text) + + case text + when nil then " " + else text.to_s + end + end + def _process_options(options) if status = options.delete(:status) response.status = status.to_i |