Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 496725022a09cd2100e1550745064fb5a6308ee4 1 parent 8eb73f4
David Heinemeier Hansson authored April 06, 2006
2  actionpack/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *1.12.1* (April 6th, 2005)
2 2
 
  3
+* Fixed that template extensions would be cached development mode #4624 [Stefan Kaes]
  4
+
3 5
 * Update to Prototype 1.5.0_rc0 [Sam Stephenson]
4 6
 
5 7
 * 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.]
36  actionpack/lib/action_view/base.rb
@@ -157,6 +157,11 @@ class Base
157 157
     @@cache_template_loading = false
158 158
     cattr_accessor :cache_template_loading
159 159
 
  160
+    # Specify whether file extension lookup should be cached.
  161
+    # Should be +false+ for development environments. Defaults to +true+.
  162
+    @@cache_template_extensions = true
  163
+    cattr_accessor :cache_template_extensions
  164
+
160 165
     # Specify whether local_assigns should be able to use string keys.
161 166
     # Defaults to +true+. String keys are deprecated and will be removed
162 167
     # shortly.
@@ -312,15 +317,11 @@ def compile_and_render_template(extension, template = nil, file_path = nil, loca
312 317
     end
313 318
 
314 319
     def pick_template_extension(template_path)#:nodoc:
315  
-      @@cached_template_extension[template_path] ||=
316  
-        if match = delegate_template_exists?(template_path)
317  
-          match.first.to_sym
318  
-        elsif erb_template_exists?(template_path):        :rhtml
319  
-        elsif builder_template_exists?(template_path):    :rxml
320  
-        elsif javascript_template_exists?(template_path): :rjs
321  
-        else
322  
-          raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path}"
323  
-        end
  320
+      if @@cache_template_extensions
  321
+        @@cached_template_extension[template_path] ||= find_template_extension_for(template_path)
  322
+      else
  323
+        find_template_extension_for(template_path)
  324
+      end
324 325
     end
325 326
 
326 327
     def delegate_template_exists?(template_path)#:nodoc:
@@ -345,7 +346,7 @@ def file_exists?(template_path)#:nodoc:
345 346
       if template_file_extension
346 347
         template_exists?(template_file_name, template_file_extension)
347 348
       else
348  
-        @@cached_template_extension[template_path] ||
  349
+        cached_template_extension(template_path) ||
349 350
            %w(erb builder javascript delegate).any? do |template_type| 
350 351
              send("#{template_type}_template_exists?", template_path)
351 352
            end
@@ -371,6 +372,21 @@ def path_and_extension(template_path)
371 372
         template_path_without_extension = template_path.sub(/\.(\w+)$/, '')
372 373
         [ template_path_without_extension, $1 ]
373 374
       end
  375
+      
  376
+      def cached_template_extension(template_path)
  377
+        @@cache_template_extensions && @@cached_template_extension[template_path]
  378
+      end      
  379
+          
  380
+      def find_template_extension_for(template_path)
  381
+        if match = delegate_template_exists?(template_path)
  382
+          match.first.to_sym
  383
+        elsif erb_template_exists?(template_path):        :rhtml
  384
+        elsif builder_template_exists?(template_path):    :rxml
  385
+        elsif javascript_template_exists?(template_path): :rjs
  386
+        else
  387
+          raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path}"
  388
+        end
  389
+      end
374 390
 
375 391
       # This method reads a template file.
376 392
       def read_template_file(template_path, extension)
1  railties/environments/development.rb
@@ -14,6 +14,7 @@
14 14
 # Show full error reports and disable caching
15 15
 config.action_controller.consider_all_requests_local = true
16 16
 config.action_controller.perform_caching             = false
  17
+config.action_view.cache_template_extensions         = false
17 18
 config.action_view.debug_rjs                         = true
18 19
 
19 20
 # Don't care if the mailer can't send

0 notes on commit 4967250

Please sign in to comment.
Something went wrong with that request. Please try again.