提交 7407d35c 编写于 作者: T Toshimaru

Enable `block` variable in view

Remove `block` keyword from reserved method names
上级 a0aad038
......@@ -326,7 +326,7 @@ def handle_render_error(view, e) #:nodoc:
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
......
......@@ -14,6 +14,10 @@ def test_template_with_ruby_keyword_locals
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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册