From 11a51648ad956de2b363810265d78eeebdeec836 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 26 Jul 2005 12:37:21 +0000 Subject: 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 --- actionpack/lib/action_view/base.rb | 12 ++++++++---- 1 file 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 -- cgit v1.2.3