Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dhh committed Jul 26, 2005
1 parent 36fee9c commit 11a5164
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions actionpack/lib/action_view/base.rb
Expand Up @@ -269,11 +269,15 @@ def template_exists?(template_path, extension)

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

Expand Down

0 comments on commit 11a5164

Please sign in to comment.