diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-03-19 13:35:39 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-03-19 13:35:39 -0700 |
commit | 8ab37c76608d7105c47566e79b85fcf72cb11e4b (patch) | |
tree | 590cac61655bdb00d2df7015b515bc125e4c8b10 /actionpack/lib/action_controller/new_base | |
parent | e0447023db7152d3ecdf693bd9aa36c7daa02653 (diff) | |
download | rails-8ab37c76608d7105c47566e79b85fcf72cb11e4b.tar.gz rails-8ab37c76608d7105c47566e79b85fcf72cb11e4b.tar.bz2 rails-8ab37c76608d7105c47566e79b85fcf72cb11e4b.zip |
Started implementing render :action
Diffstat (limited to 'actionpack/lib/action_controller/new_base')
-rw-r--r-- | actionpack/lib/action_controller/new_base/renderer.rb | 52 |
1 files changed, 42 insertions, 10 deletions
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 |