未验证 提交 92d3afe4 编写于 作者: J John Hawthorn 提交者: GitHub

Merge pull request #39068 from jhawthorn/dependency_tracker_interpolation

Ignore interpolated strings in DependencyTracker
......@@ -130,8 +130,9 @@ def render_dependencies
def add_dependencies(render_dependencies, arguments, pattern)
arguments.scan(pattern) do
add_dynamic_dependency(render_dependencies, Regexp.last_match[:dynamic])
add_static_dependency(render_dependencies, Regexp.last_match[:static])
match = Regexp.last_match
add_dynamic_dependency(render_dependencies, match[:dynamic])
add_static_dependency(render_dependencies, match[:static], match[:quote])
end
end
......@@ -141,7 +142,12 @@ def add_dynamic_dependency(dependencies, dependency)
end
end
def add_static_dependency(dependencies, dependency)
def add_static_dependency(dependencies, dependency, quote_type)
if quote_type == '"'
# Ignore if there is interpolation
return if dependency.include?('#{')
end
if dependency
if dependency.include?("/")
dependencies << dependency
......
......@@ -192,4 +192,14 @@ def test_finds_dependencies_with_extra_spaces
"comments/comment"
], tracker.dependencies
end
def test_dependencies_with_interpolation
template = FakeTemplate.new(%q{
<%# render "double/#{quote}" %>
<%# render 'single/#{quote}' %>
}, :erb)
tracker = make_tracker("interpolation/_string", template)
assert_equal ["single/\#{quote}"], tracker.dependencies
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册