aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r--actionpack/lib/action_view/base.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index efd2824236..dfe421c312 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -432,21 +432,27 @@ module ActionView #:nodoc:
# Check whether compilation is necessary.
# Compile if the inline template or file has not been compiled yet.
# Or if local_assigns has a new key, which isn't supported by the compiled code yet.
- # Or if the file has changed on disk and checking file mods hasn't been disabled.
+ # Or if the file has changed on disk and checking file mods hasn't been disabled.
def compile_template?(template, file_name, local_assigns)
method_key = file_name || template
render_symbol = @@method_names[method_key]
if @@compile_time[render_symbol] && supports_local_assigns?(render_symbol, local_assigns)
- if file_name && !@@cache_template_loading
- @@compile_time[render_symbol] < File.mtime(file_name) ||
- (File.symlink?(file_name) && (@@compile_time[render_symbol] < File.lstat(file_name).mtime))
+ if file_name && !@@cache_template_loading
+ template_changed_since?(file_name, @@compile_time[render_symbol])
end
else
true
end
end
+ # handles checking if template changed since last compile, isolated so that templates
+ # not stored on the file system can hook and extend appropriately
+ def template_changed_since?(file_name, compile_time)
+ compile_time < File.mtime(file_name) ||
+ (File.symlink?(file_name) && (compile_time < File.lstat(file_name).mtime))
+ end
+
# Create source code for given template
def create_template_source(extension, template, render_symbol, locals)
if template_requires_setup?(extension)