diff options
author | Dov Murik <dov.murik@gmail.com> | 2015-06-01 21:56:31 -0400 |
---|---|---|
committer | Dov Murik <dov.murik@gmail.com> | 2015-06-22 14:17:08 -0400 |
commit | d51e2eefd5c50cef366ddc96a3b93af0395755f1 (patch) | |
tree | 61d6475f706b28f7b25551a04ae6718ac5d5863c /actionview/lib/action_view/template/handlers | |
parent | ccdefa0e230dac72ae35e41791ec5fa53117e91e (diff) | |
download | rails-d51e2eefd5c50cef366ddc96a3b93af0395755f1.tar.gz rails-d51e2eefd5c50cef366ddc96a3b93af0395755f1.tar.bz2 rails-d51e2eefd5c50cef366ddc96a3b93af0395755f1.zip |
Improve detection of partial templates eligible for collection caching.
The regular expression which was used to detect partial templates that
begin with a `<% cache ... do %>` call missed some cases. This commits
attempts to improve the detection for some cases such as multi-line
comments at the beginning of the template. The different templates are
listed in two new unit test methods.
Note that specially crafted Ruby code can still evade such `cache`-call
detection: for example, a user might have its own method which itself
calls the Rails `cache` helper. In such a case, the template's code
doesn't start with a literal `cache` string and therefore will not be
eligible for collection caching.
Diffstat (limited to 'actionview/lib/action_view/template/handlers')
-rw-r--r-- | actionview/lib/action_view/template/handlers/erb.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index 88a8570706..da96347e4d 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -138,7 +138,7 @@ module ActionView # # <% cache notification.event do %> # => nil def resource_cache_call_pattern - /\A(?:<%#.*%>\n?)?<% cache\(?\s*(\w+\.?)/ + /\A(?:<%#.*%>)*\s*<%\s*cache\(?\s*(\w+)[\s\)]/m end private |