From d41f380a2c7c7926ce89ee2bcef8093d1fd59036 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 20 Nov 2006 09:04:26 +0000 Subject: Extract template_changed_since? from compile_template? so plugins may override its behavior for non-file-based templates. Closes #6651. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5587 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/base.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'actionpack/lib') 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) -- cgit v1.2.3