From 41ea6963a38880e47dbc1cd75dd91a1df184ba66 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 23 Feb 2005 14:57:08 +0000 Subject: 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 --- actionpack/lib/action_controller/base.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'actionpack/lib') 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: # * :host -- overrides the default (current) host if provided # * :protocol -- 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 @params. + # The URL is generated from the remaining keys in the hash. A URL contains two key parts: the and a query string. + # Routes composes a query string as the key/value pairs not included in the . #   # 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. -- cgit v1.2.3