diff options
Diffstat (limited to 'actionpack/lib/action_controller/base')
-rw-r--r-- | actionpack/lib/action_controller/base/render.rb | 16 | ||||
-rw-r--r-- | actionpack/lib/action_controller/base/responder.rb | 21 |
2 files changed, 22 insertions, 15 deletions
diff --git a/actionpack/lib/action_controller/base/render.rb b/actionpack/lib/action_controller/base/render.rb index 0d24f18633..606df58518 100644 --- a/actionpack/lib/action_controller/base/render.rb +++ b/actionpack/lib/action_controller/base/render.rb @@ -1,3 +1,5 @@ +require 'action_controller/abstract/renderer' + module ActionController DEFAULT_RENDER_STATUS_CODE = "200 OK" @@ -306,9 +308,9 @@ module ActionController (name.is_a?(String) ? name.sub(/^#{controller_path}\//, '') : name).to_s end - # Renders according to the same rules as <tt>render</tt>, but returns the result in a string instead - # of sending it as the response body to the browser. - def render_to_string(options = nil, &block) #:doc: + # Same rules as <tt>render</tt>, but returns a Rack-compatible body + # instead of sending the response. + def render_to_body(options = nil, &block) #:doc: render(options, &block) response.body ensure @@ -316,7 +318,11 @@ module ActionController erase_render_results reset_variables_added_to_assigns end - + + def render_to_string(options = {}) + AbstractController::Renderer.body_to_s(render_to_body(options)) + end + # Clears the rendered results, allowing for another render to be performed. def erase_render_results #:nodoc: response.body = [] @@ -387,4 +393,4 @@ module ActionController render_for_parts(parts, layout, options) end end -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_controller/base/responder.rb b/actionpack/lib/action_controller/base/responder.rb index 989f82444b..1aee980da6 100644 --- a/actionpack/lib/action_controller/base/responder.rb +++ b/actionpack/lib/action_controller/base/responder.rb @@ -5,18 +5,19 @@ module ActionController end private - def render_for_text(text = nil, append_response = false) #:nodoc: + def render_for_text(text) #:nodoc: @performed_render = true - if append_response - response.body ||= '' - response.body << text.to_s - else - response.body = case text - when Proc then text - when nil then " " # Safari doesn't pass the headers of the return if the response is zero length - else text.to_s + case text + when Proc + response.body = text + when nil + # Safari 2 doesn't pass response headers if the response is zero-length + if response.body_parts.empty? + response.body_parts << ' ' end + else + response.body_parts << text end end @@ -39,4 +40,4 @@ module ActionController end end end -end
\ No newline at end of file +end |