aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-04-06 18:08:31 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-04-06 18:08:31 +0000
commit496725022a09cd2100e1550745064fb5a6308ee4 (patch)
treed5215d5669707ca056304ab06c5fed66ed0d6421 /actionpack/lib/action_view
parent8eb73f43e1f7eb6f7afa7838e64b259c81bc8a47 (diff)
downloadrails-496725022a09cd2100e1550745064fb5a6308ee4.tar.gz
rails-496725022a09cd2100e1550745064fb5a6308ee4.tar.bz2
rails-496725022a09cd2100e1550745064fb5a6308ee4.zip
Fixed that template extensions would be cached development mode #4624 [Stefan Kaes]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4189 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/base.rb36
1 files changed, 26 insertions, 10 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 3e73159d26..2ee4227a6f 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -157,6 +157,11 @@ module ActionView #:nodoc:
@@cache_template_loading = false
cattr_accessor :cache_template_loading
+ # Specify whether file extension lookup should be cached.
+ # Should be +false+ for development environments. Defaults to +true+.
+ @@cache_template_extensions = true
+ cattr_accessor :cache_template_extensions
+
# Specify whether local_assigns should be able to use string keys.
# Defaults to +true+. String keys are deprecated and will be removed
# shortly.
@@ -312,15 +317,11 @@ module ActionView #:nodoc:
end
def pick_template_extension(template_path)#:nodoc:
- @@cached_template_extension[template_path] ||=
- if match = delegate_template_exists?(template_path)
- match.first.to_sym
- elsif erb_template_exists?(template_path): :rhtml
- elsif builder_template_exists?(template_path): :rxml
- elsif javascript_template_exists?(template_path): :rjs
- else
- raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path}"
- end
+ if @@cache_template_extensions
+ @@cached_template_extension[template_path] ||= find_template_extension_for(template_path)
+ else
+ find_template_extension_for(template_path)
+ end
end
def delegate_template_exists?(template_path)#:nodoc:
@@ -345,7 +346,7 @@ module ActionView #:nodoc:
if template_file_extension
template_exists?(template_file_name, template_file_extension)
else
- @@cached_template_extension[template_path] ||
+ cached_template_extension(template_path) ||
%w(erb builder javascript delegate).any? do |template_type|
send("#{template_type}_template_exists?", template_path)
end
@@ -371,6 +372,21 @@ module ActionView #:nodoc:
template_path_without_extension = template_path.sub(/\.(\w+)$/, '')
[ template_path_without_extension, $1 ]
end
+
+ def cached_template_extension(template_path)
+ @@cache_template_extensions && @@cached_template_extension[template_path]
+ end
+
+ def find_template_extension_for(template_path)
+ if match = delegate_template_exists?(template_path)
+ match.first.to_sym
+ elsif erb_template_exists?(template_path): :rhtml
+ elsif builder_template_exists?(template_path): :rxml
+ elsif javascript_template_exists?(template_path): :rjs
+ else
+ raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path}"
+ end
+ end
# This method reads a template file.
def read_template_file(template_path, extension)