aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/abstract
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-04-23 01:09:27 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-04-23 01:09:27 +0100
commit5a1fe9039b33414b7088813712e03bbe38567cff (patch)
tree10e3a15c06494dd09c0324dca894ddcbb68ce582 /actionpack/lib/action_controller/abstract
parent3384f073e35c5391deaeb209a62a485a0c4dd7b1 (diff)
parent7f6779c1d5e4ec7f642839caa7e86320720f77c8 (diff)
downloadrails-5a1fe9039b33414b7088813712e03bbe38567cff.tar.gz
rails-5a1fe9039b33414b7088813712e03bbe38567cff.tar.bz2
rails-5a1fe9039b33414b7088813712e03bbe38567cff.zip
Merge commit 'mainstream/master'
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
-rw-r--r--actionpack/lib/action_controller/abstract/renderer.rb30
1 files changed, 26 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb
index 68c3b07b84..a86eef889e 100644
--- a/actionpack/lib/action_controller/abstract/renderer.rb
+++ b/actionpack/lib/action_controller/abstract/renderer.rb
@@ -17,28 +17,50 @@ module AbstractController
end
def render(options = {})
- self.response_body = render_to_string(options)
+ self.response_body = render_to_body(options)
end
- # Raw rendering of a template.
+ # Raw rendering of a template to a Rack-compatible body.
# ====
# @option _prefix<String> The template's path prefix
# @option _layout<String> The relative path to the layout template to use
#
# :api: plugin
- def render_to_string(options = {})
+ def render_to_body(options = {})
name = options[:_template_name] || action_name
template = options[:_template] || view_paths.find_by_parts(name.to_s, formats, options[:_prefix])
_render_template(template, options)
end
+ # Raw rendering of a template to a string.
+ # ====
+ # @option _prefix<String> The template's path prefix
+ # @option _layout<String> The relative path to the layout template to use
+ #
+ # :api: plugin
+ def render_to_string(options = {})
+ AbstractController::Renderer.body_to_s(render_to_body(options))
+ end
+
def _render_template(template, options)
_action_view._render_template_with_layout(template)
end
def view_paths() _view_paths end
+ # Return a string representation of a Rack-compatible response body.
+ def self.body_to_s(body)
+ if body.respond_to?(:to_str)
+ body
+ else
+ strings = []
+ body.each { |part| strings << part.to_s }
+ body.close if body.respond_to?(:close)
+ strings.join
+ end
+ end
+
module ClassMethods
def append_view_path(path)
@@ -55,4 +77,4 @@ module AbstractController
end
end
end
-end \ No newline at end of file
+end