aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-23 14:57:08 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-23 14:57:08 +0000
commit41ea6963a38880e47dbc1cd75dd91a1df184ba66 (patch)
treec1438c5d500d19a0887df329bd4dd98f5b36c530 /actionpack/lib
parenta8f36e88dd322f78efe0a54eb73a7e3b9fd60479 (diff)
downloadrails-41ea6963a38880e47dbc1cd75dd91a1df184ba66.tar.gz
rails-41ea6963a38880e47dbc1cd75dd91a1df184ba66.tar.bz2
rails-41ea6963a38880e47dbc1cd75dd91a1df184ba66.zip
Added Base#render_to_string to parse a template and get the result back as a string #479
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@766 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/base.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index fa7380f9b5..8b02731510 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -341,10 +341,8 @@ module ActionController #:nodoc:
# * <tt>:host</tt> -- overrides the default (current) host if provided
# * <tt>:protocol</tt> -- overrides the default (current) protocol if provided
#  
- # All other keys are used to generate an appropriate path for the new URL. This is handled by the Routes mechanism,
- # and the generated path is wildly configurable. The options that Routes does not use are
- # are encoded into a typical query string. Once (and if) the link is followed, all provided options are made
- # available to the controller in <tt>@params</tt>.
+ # The URL is generated from the remaining keys in the hash. A URL contains two key parts: the <base> and a query string.
+ # Routes composes a query string as the key/value pairs not included in the <base>.
#  
# The default Routes setup supports a typical Rails path of "controller/action/id" where action and id are optional, with
# action defaulting to 'index' when not given. Here are some typical url_for statements and their corresponding URLs:
@@ -478,6 +476,12 @@ module ActionController #:nodoc:
render_text "", status
end
+ # Returns the result of the render as a string.
+ def render_to_string(template_name = default_template_name)
+ add_variables_to_assigns
+ @template.render_file(template_name)
+ end
+
# Sends the file by streaming it 4096 bytes at a time. This way the
# whole file doesn't need to be read into memory at once. This makes
# it feasible to send even large files.