diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/template.rb | 2 | ||||
-rw-r--r-- | actionview/test/fixtures/test/test_template_with_block_variable.erb | 1 | ||||
-rw-r--r-- | actionview/test/template/compiled_templates_test.rb | 4 |
3 files changed, 6 insertions, 1 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 2dcd6324db..d67f37d6d1 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -326,7 +326,7 @@ module ActionView def locals_code #:nodoc: # Only locals with valid variable names get set directly. Others will # still be available in local_assigns. - locals = @locals.to_set - Module::DELEGATION_RESERVED_METHOD_NAMES + locals = @locals.to_set - Module::DELEGATION_RESERVED_METHOD_NAMES.dup.delete("block") locals = locals.grep(/\A(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/) # Double assign to suppress the dreaded 'assigned but unused variable' warning diff --git a/actionview/test/fixtures/test/test_template_with_block_variable.erb b/actionview/test/fixtures/test/test_template_with_block_variable.erb new file mode 100644 index 0000000000..2ee6a2bbdc --- /dev/null +++ b/actionview/test/fixtures/test/test_template_with_block_variable.erb @@ -0,0 +1 @@ +<%= block %>
\ No newline at end of file diff --git a/actionview/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb index 3ecac46d34..a24a245442 100644 --- a/actionview/test/template/compiled_templates_test.rb +++ b/actionview/test/template/compiled_templates_test.rb @@ -14,6 +14,10 @@ class CompiledTemplatesTest < ActiveSupport::TestCase render(file: "test/render_file_with_ruby_keyword_locals", locals: { class: "foo" }) end + def test_template_with_block_variable + assert_equal "foo", render(file: "test/test_template_with_block_variable", locals: { block: "foo" }) + end + def test_template_with_invalid_identifier_locals locals = { foo: "bar", |