aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/rendering.rb7
-rw-r--r--actionview/test/actionpack/controller/render_test.rb9
2 files changed, 14 insertions, 2 deletions
diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb
index abd3b77c67..1e8e7415d1 100644
--- a/actionview/lib/action_view/rendering.rb
+++ b/actionview/lib/action_view/rendering.rb
@@ -92,12 +92,15 @@ module ActionView
# Find and render a template based on the options given.
# :api: private
def _render_template(options) #:nodoc:
- variant = options[:variant]
+ variant = options.delete(:variant)
+ assigns = options.delete(:assigns)
+ context = view_context
+ context.assign assigns if assigns
lookup_context.rendered_format = nil if options[:formats]
lookup_context.variants = variant if variant
- view_renderer.render(view_context, options)
+ view_renderer.render(context, options)
end
# Assign the rendered format to lookup context.
diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb
index 563caee8a2..94f519e330 100644
--- a/actionview/test/actionpack/controller/render_test.rb
+++ b/actionview/test/actionpack/controller/render_test.rb
@@ -453,6 +453,10 @@ class TestController < ApplicationController
render :text => "foo"
end
+ def render_with_assigns_option
+ render inline: '<%= @hello %>', assigns: { hello: "world" }
+ end
+
def yield_content_for
render :action => "content_for", :layout => "yield"
end
@@ -1102,6 +1106,11 @@ class RenderTest < ActionController::TestCase
assert_equal "world", assigns["hello"]
end
+ def test_render_text_with_assigns_option
+ get :render_with_assigns_option
+ assert_equal 'world', response.body
+ end
+
# :ported:
def test_template_with_locals
get :render_with_explicit_template_with_locals