0
@@ -157,6 +157,11 @@ module ActionView #:nodoc:
0
@@cache_template_loading = false
0
cattr_accessor :cache_template_loading
0
+ # Specify whether file extension lookup should be cached.
0
+ # Should be +false+ for development environments. Defaults to +true+.
0
+ @@cache_template_extensions = true
0
+ cattr_accessor :cache_template_extensions
0
# Specify whether local_assigns should be able to use string keys.
0
# Defaults to +true+. String keys are deprecated and will be removed
0
@@ -312,15 +317,11 @@ module ActionView #:nodoc:
0
def pick_template_extension(template_path)#:nodoc:
0
- @@cached_template_extension[template_path] ||=
0
- if match = delegate_template_exists?(template_path)
0
- elsif erb_template_exists?(template_path): :rhtml
0
- elsif builder_template_exists?(template_path): :rxml
0
- elsif javascript_template_exists?(template_path): :rjs
0
- raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path}"
0
+ if @@cache_template_extensions
0
+ @@cached_template_extension[template_path] ||= find_template_extension_for(template_path)
0
+ find_template_extension_for(template_path)
0
def delegate_template_exists?(template_path)#:nodoc:
0
@@ -345,7 +346,7 @@ module ActionView #:nodoc:
0
if template_file_extension
0
template_exists?(template_file_name, template_file_extension)
0
-
@@cached_template_extension[template_path] ||
0
+
cached_template_extension(template_path) ||
0
%w(erb builder javascript delegate).any? do |template_type|
0
send("#{template_type}_template_exists?", template_path)
0
@@ -371,6 +372,21 @@ module ActionView #:nodoc:
0
template_path_without_extension = template_path.sub(/\.(\w+)$/, '')
0
[ template_path_without_extension, $1 ]
0
+ def cached_template_extension(template_path)
0
+ @@cache_template_extensions && @@cached_template_extension[template_path]
0
+ def find_template_extension_for(template_path)
0
+ if match = delegate_template_exists?(template_path)
0
+ elsif erb_template_exists?(template_path): :rhtml
0
+ elsif builder_template_exists?(template_path): :rxml
0
+ elsif javascript_template_exists?(template_path): :rjs
0
+ raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path}"
0
# This method reads a template file.
0
def read_template_file(template_path, extension)
Comments
No one has commented yet.