aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-10-13 20:26:39 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-10-13 20:26:39 +0000
commit43b6a74fb188e41ae686c2d948e876c1f84e7bdf (patch)
tree10cf1fedda61f2d9f4fc97812cbfd843902079e6 /actionpack
parente646786a76fbb8091ae3c370ff3b3a82e30fa63f (diff)
downloadrails-43b6a74fb188e41ae686c2d948e876c1f84e7bdf.tar.gz
rails-43b6a74fb188e41ae686c2d948e876c1f84e7bdf.tar.bz2
rails-43b6a74fb188e41ae686c2d948e876c1f84e7bdf.zip
Added :locals support for render :inline #2463 [mdabney@cavoksolutions.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2567 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb6
-rw-r--r--actionpack/test/controller/render_test.rb11
3 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 7c9251dce7..906e44ec9b 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added :locals support for render :inline #2463 [mdabney@cavoksolutions.com]
+
* Unset the X-Requested-With header when using the xhr wrapper in functional tests so that future requests aren't accidentally xhr'ed #2352 [me@julik.nl, Sam Stephenson]
* Unescape paths before writing cache to file system. #1877. [Damien Pollet]
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index cc13bfef14..a019a4e1fc 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -590,7 +590,7 @@ module ActionController #:nodoc:
render_file(template, options[:status], true)
elsif inline = options[:inline]
- render_template(inline, options[:status], options[:type])
+ render_template(inline, options[:status], options[:type], options[:locals] || {})
elsif action_name = options[:action]
render_action(action_name, options[:status], options[:layout])
@@ -637,9 +637,9 @@ module ActionController #:nodoc:
render_text(@template.render_file(template_path, use_full_path), status)
end
- def render_template(template, status = nil, type = :rhtml)
+ def render_template(template, status = nil, type = :rhtml, local_assigns = {})
add_variables_to_assigns
- render_text(@template.render_template(type, template), status)
+ render_text(@template.render_template(type, template, nil, local_assigns), status)
end
def render_text(text = nil, status = nil)
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 0a86cc914e..cd7c32e0a2 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -75,6 +75,11 @@ class TestController < ActionController::Base
render_template "Hello: <%= params[:name] %>"
end
+ def accessing_local_assigns_in_inline_template
+ name = params[:local_name]
+ render :inline => "<%= 'Goodbye, ' + local_name %>", :locals => { :local_name => name }
+ end
+
def rescue_action(e) raise end
private
@@ -206,6 +211,12 @@ class RenderTest < Test::Unit::TestCase
assert_equal "Hello: David", process_request.body
end
+ def test_accessing_local_assigns_in_inline_template
+ @request.action = "accessing_local_assigns_in_inline_template"
+ @request.query_parameters[:local_name] = "Local David"
+ assert_equal "Goodbye, Local David", process_request.body
+ end
+
private
def process_request
TestController.process(@request, @response)