提交 c577657f 编写于 作者: A Akira Matsuda

Merge pull request #24052 from bquorning/partial-rendering-with-collection-and-dot-in-partial-name

Fix partial rendering with dot in filename
......@@ -521,7 +521,7 @@ def retrieve_template_keys
def retrieve_variable(path, as)
variable = as || begin
base = path[-1] == "/".freeze ? "".freeze : File.basename(path)
raise_invalid_identifier(path) unless base =~ /\A_?(.*)(?:\.\w+)*\z/
raise_invalid_identifier(path) unless base =~ /\A_?(.*?)(\.\w+)*\z/
$1.to_sym
end
if @collection
......
Hello: <%= customer.name rescue "Anonymous" %>
\ No newline at end of file
......@@ -270,6 +270,11 @@ def test_render_partial_collection
assert_equal "Hello: davidHello: mary", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), Customer.new("mary") ])
end
def test_render_partial_collection_with_partial_name_containing_dot
assert_equal "Hello: davidHello: mary",
@view.render(:partial => "test/customer.mobile", :collection => [ Customer.new("david"), Customer.new("mary") ])
end
def test_render_partial_collection_as_by_string
assert_equal "david david davidmary mary mary",
@view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => 'customer')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册