Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dhh committed Apr 6, 2006
1 parent 8eb73f4 commit 4967250
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*1.12.1* (April 6th, 2005)

* Fixed that template extensions would be cached development mode #4624 [Stefan Kaes]

* Update to Prototype 1.5.0_rc0 [Sam Stephenson]

* Honor skipping filters conditionally for only certain actions even when the parent class sets that filter to conditionally be executed only for the same actions. #4522 [Marcel Molina Jr.]
Expand Down
36 changes: 26 additions & 10 deletions actionpack/lib/action_view/base.rb
Expand Up @@ -157,6 +157,11 @@ class Base
@@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.
Expand Down Expand Up @@ -312,15 +317,11 @@ def compile_and_render_template(extension, template = nil, file_path = nil, loca
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:
Expand All @@ -345,7 +346,7 @@ def file_exists?(template_path)#: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
Expand All @@ -371,6 +372,21 @@ def path_and_extension(template_path)
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)
Expand Down
1 change: 1 addition & 0 deletions railties/environments/development.rb
Expand Up @@ -14,6 +14,7 @@
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_view.cache_template_extensions = false
config.action_view.debug_rjs = true

# Don't care if the mailer can't send
Expand Down

0 comments on commit 4967250

Please sign in to comment.