Skip to content
This repository
Browse code

Fix rendering html partial via inline render when with :js format [#1399

state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit 60d6f255177af3ca93721abb8551c8585fc8c67d 1 parent 9c01d3c
Luke Melia authored November 18, 2008 josh committed November 18, 2008
3  actionpack/lib/action_view/base.rb
@@ -317,7 +317,8 @@ def _pick_template(template_path)
317 317
           template
318 318
         elsif template = self.view_paths[template_file_name]
319 319
           template
320  
-        elsif @_render_stack.first && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"]
  320
+        elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) &&
  321
+            (template = self.view_paths["#{template_file_name}.#{first_render.format_and_extension}"])
321 322
           template
322 323
         elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"]
323 324
           @template_format = :html
14  actionpack/test/controller/render_test.rb
@@ -246,6 +246,15 @@ def accessing_local_assigns_in_inline_template
246 246
            :locals => { :local_name => name }
247 247
   end
248 248
 
  249
+  def helper_method_to_render_to_string(*args)
  250
+    render_to_string(*args)
  251
+  end
  252
+  helper_method :helper_method_to_render_to_string
  253
+
  254
+  def render_html_only_partial_within_inline
  255
+    render :inline => "Hello world <%= helper_method_to_render_to_string :partial => 'test/partial_with_only_html_version' %>"
  256
+  end
  257
+
249 258
   def formatted_html_erb
250 259
   end
251 260
 
@@ -932,6 +941,11 @@ def test_accessing_local_assigns_in_inline_template
932 941
     assert_equal "Goodbye, Local David", @response.body
933 942
   end
934 943
 
  944
+  def test_rendering_html_only_partial_within_inline_with_js
  945
+    get :render_html_only_partial_within_inline, :format => :js
  946
+    assert_equal "Hello world partial with only html version", @response.body
  947
+  end
  948
+
935 949
   def test_should_render_formatted_template
936 950
     get :formatted_html_erb
937 951
     assert_equal 'formatted html erb', @response.body
1  actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb
... ...
@@ -0,0 +1 @@
  1
+partial with only html version

0 notes on commit 60d6f25

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