diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-20 09:04:26 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-20 09:04:26 +0000 |
commit | d41f380a2c7c7926ce89ee2bcef8093d1fd59036 (patch) | |
tree | c5fdfc4ef646b81e7b9a840edf9b11451b4e425f /actionpack/lib | |
parent | 19c99acfbc26c5fad02d968f37a958b1cbfa617b (diff) | |
download | rails-d41f380a2c7c7926ce89ee2bcef8093d1fd59036.tar.gz rails-d41f380a2c7c7926ce89ee2bcef8093d1fd59036.tar.bz2 rails-d41f380a2c7c7926ce89ee2bcef8093d1fd59036.zip |
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
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 14 |
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) |