mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #39068 from jhawthorn/dependency_tracker_interpolation
Ignore interpolated strings in DependencyTracker
This commit is contained in:
commit
92d3afe475
2 changed files with 19 additions and 3 deletions
|
@ -130,8 +130,9 @@ module ActionView
|
||||||
|
|
||||||
def add_dependencies(render_dependencies, arguments, pattern)
|
def add_dependencies(render_dependencies, arguments, pattern)
|
||||||
arguments.scan(pattern) do
|
arguments.scan(pattern) do
|
||||||
add_dynamic_dependency(render_dependencies, Regexp.last_match[:dynamic])
|
match = Regexp.last_match
|
||||||
add_static_dependency(render_dependencies, Regexp.last_match[:static])
|
add_dynamic_dependency(render_dependencies, match[:dynamic])
|
||||||
|
add_static_dependency(render_dependencies, match[:static], match[:quote])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,7 +142,12 @@ module ActionView
|
||||||
end
|
end
|
||||||
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
|
||||||
if dependency.include?("/")
|
if dependency.include?("/")
|
||||||
dependencies << dependency
|
dependencies << dependency
|
||||||
|
|
|
@ -192,4 +192,14 @@ class ERBTrackerTest < Minitest::Test
|
||||||
"comments/comment"
|
"comments/comment"
|
||||||
], tracker.dependencies
|
], tracker.dependencies
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue