aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-26 12:37:21 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-26 12:37:21 +0000
commit11a51648ad956de2b363810265d78eeebdeec836 (patch)
tree54de1f4130a840f9241936d303adf8841637d0d3 /actionpack
parent36fee9c02eef3f0d6bf2f60b46b37376225d07c1 (diff)
downloadrails-11a51648ad956de2b363810265d78eeebdeec836.tar.gz
rails-11a51648ad956de2b363810265d78eeebdeec836.tar.bz2
rails-11a51648ad956de2b363810265d78eeebdeec836.zip
Document the design of the compiled templates approach and tweak the expiration check
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1929 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/base.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 7fc0c3b020..95ee177314 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -269,11 +269,15 @@ module ActionView #:nodoc:
def read_template_file(template_path, extension)
info = @@loaded_templates[template_path]
- read_file = info.nil? || ( info.is_a?(Time) ?
- info < File.stat(template_path).mtime :
- !@@cache_template_loading )
+ # info is either the template source code, or the its compile time, or nil
+ # if nil, we need to read it from the file system
+ # if it is a time, we need to reread it if it has changed on disk
+ # if @@cache_template_loading is true, we will never reread
+ unless read_file = info.nil?
+ read_file = !@@cache_template_loading && info.is_a?(Time) && info < File.stat(template_path).mtime
+ end
if read_file
- @@loaded_templates[template_path] = info = File.read(template_path)
+ info = @@loaded_templates[template_path] = File.read(template_path)
@@compiled_templates[template_path] = nil
end