public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Made ActionView::Base#first_render a little more private. And added _last_render 
to track the most recent render. Will fix #609 as a side effect. [#609 
state:resolved]
josh (author)
Sun Jul 13 11:26:48 -0700 2008
commit  e0fef66149092dd3d2988fff64f0ce8765735687
tree    76b20ee8e265f74610eb2836be5bc27c300da2a4
parent  99cc85bc099a757cdd44e4f5f1be4972ab124e0d
...
87
88
89
90
 
91
92
93
94
 
95
96
97
...
87
88
89
 
90
91
92
93
 
94
95
96
97
0
@@ -87,11 +87,11 @@ module ActionController
0
       #
0
       def assert_template(expected = nil, message=nil)
0
         clean_backtrace do
0
-          rendered = expected ? @response.rendered_file(!expected.include?('/')) : @response.rendered_file
0
+          rendered = @response.rendered_template.to_s
0
           msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
0
           assert_block(msg) do
0
             if expected.nil?
0
-              !@response.rendered_with_file?
0
+              @response.rendered_template ? true : false
0
             else
0
               rendered.match(expected)
0
             end
...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
 
 
 
 
219
220
221
...
205
206
207
 
 
 
 
 
 
 
 
 
 
 
208
209
210
211
212
213
214
0
@@ -205,17 +205,10 @@ module ActionController #:nodoc:
0
       p.match(redirect_url) != nil
0
     end
0
 
0
-    # Returns the template path of the file which was used to
0
-    # render this response (or nil) 
0
-    def rendered_file(with_controller = false)
0
-      if template.first_render
0
-        template.first_render.to_s
0
-      end
0
-    end
0
-
0
-    # Was this template rendered by a file?
0
-    def rendered_with_file?
0
-      !rendered_file.nil?
0
+    # Returns the template of the file which was used to
0
+    # render this response (or nil)
0
+    def rendered_template
0
+      template._first_render
0
     end
0
 
0
     # A shortcut to the flash. Returns an empyt hash if no session flash exists.
...
159
160
161
162
 
163
 
164
165
166
167
168
169
...
313
314
315
316
 
317
318
319
...
159
160
161
 
162
163
164
165
166
 
167
168
169
...
313
314
315
 
316
317
318
319
0
@@ -159,11 +159,11 @@ module ActionView #:nodoc:
0
   class Base
0
     include ERB::Util
0
 
0
-    attr_accessor :base_path, :assigns, :template_extension, :first_render
0
+    attr_accessor :base_path, :assigns, :template_extension
0
     attr_accessor :controller
0
+    attr_accessor :_first_render, :_last_render
0
 
0
     attr_writer :template_format
0
-    attr_accessor :current_render_extension
0
 
0
     attr_accessor :output_buffer
0
 
0
@@ -313,7 +313,7 @@ module ActionView #:nodoc:
0
         template
0
       elsif template = self.view_paths[template_file_name]
0
         template
0
-      elsif first_render && template = self.view_paths["#{template_file_name}.#{first_render.extension}"]
0
+      elsif _first_render && template = self.view_paths["#{template_file_name}.#{_first_render.extension}"]
0
         template
0
       elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"]
0
         @template_format = :html
...
32
33
34
35
36
 
37
38
39
...
32
33
34
 
 
35
36
37
38
0
@@ -32,8 +32,7 @@ module ActionView
0
       #      <i>Topics listed alphabetically</i>
0
       #    <% end %>
0
       def cache(name = {}, options = nil, &block)
0
-        handler = Template.handler_class_for_extension(current_render_extension.to_sym)
0
-        handler.new(@controller).cache_fragment(block, name, options)
0
+        _last_render.handler.new(@controller).cache_fragment(block, name, options)
0
       end
0
     end
0
   end
...
18
19
20
21
 
 
22
23
24
25
26
...
18
19
20
 
21
22
23
 
24
25
26
0
@@ -18,9 +18,9 @@ module ActionView
0
     end
0
 
0
     def render(view, local_assigns = {})
0
-      view.first_render ||= self
0
+      view._first_render ||= self
0
+      view._last_render = self
0
       view.send(:evaluate_assigns)
0
-      view.current_render_extension = extension
0
       compile(local_assigns) if handler.compilable?
0
       handler.new(view).render(self, local_assigns)
0
     end
...
328
329
330
331
 
332
333
334
335
 
 
336
337
338
...
328
329
330
 
331
332
333
 
 
334
335
336
337
338
0
@@ -328,11 +328,11 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
0
   # check if we were rendered by a file-based template?
0
   def test_rendered_action
0
     process :nothing
0
-    assert !@response.rendered_with_file?
0
+    assert_nil @response.rendered_template
0
 
0
     process :hello_world
0
-    assert @response.rendered_with_file?
0
-    assert 'hello_world', @response.rendered_file
0
+    assert @response.rendered_template
0
+    assert 'hello_world', @response.rendered_template.to_s
0
   end
0
 
0
   # check the redirection location
...
664
665
666
 
 
 
 
 
 
 
 
667
668
669
...
664
665
666
667
668
669
670
671
672
673
674
675
676
677
0
@@ -664,6 +664,14 @@ CACHED
0
     assert_match "Fragment caching in a partial", @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial')
0
   end
0
 
0
+  def test_render_inline_before_fragment_caching
0
+    get :inline_fragment_cached
0
+    assert_response :success
0
+    assert_match /Some inline content/, @response.body
0
+    assert_match /Some cached content/, @response.body
0
+    assert_match "Some cached content", @store.read('views/test.host/functional_caching/inline_fragment_cached')
0
+  end
0
+
0
   def test_fragment_caching_in_rjs_partials
0
     xhr :get, :js_fragment_cached_with_partial
0
     assert_response :success

Comments