diff options
author | Luke Melia <luke@lukemelia.com> | 2008-11-18 15:16:43 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-11-18 15:19:16 -0600 |
commit | 60d6f255177af3ca93721abb8551c8585fc8c67d (patch) | |
tree | df193a3988854c7ba98ba5846a0f60d916de9aa5 /actionpack | |
parent | 9c01d3cead2b071d27f06690df73d6b579a18f4f (diff) | |
download | rails-60d6f255177af3ca93721abb8551c8585fc8c67d.tar.gz rails-60d6f255177af3ca93721abb8551c8585fc8c67d.tar.bz2 rails-60d6f255177af3ca93721abb8551c8585fc8c67d.zip |
Fix rendering html partial via inline render when with :js format [#1399 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 14 | ||||
-rw-r--r-- | actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 945246a39a..511858dd9b 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -317,7 +317,8 @@ module ActionView #:nodoc: template elsif template = self.view_paths[template_file_name] template - elsif @_render_stack.first && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"] + elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) && + (template = self.view_paths["#{template_file_name}.#{first_render.format_and_extension}"]) template elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"] @template_format = :html diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 462fba7045..d5320596d5 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -246,6 +246,15 @@ class TestController < ActionController::Base :locals => { :local_name => name } end + def helper_method_to_render_to_string(*args) + render_to_string(*args) + end + helper_method :helper_method_to_render_to_string + + def render_html_only_partial_within_inline + render :inline => "Hello world <%= helper_method_to_render_to_string :partial => 'test/partial_with_only_html_version' %>" + end + def formatted_html_erb end @@ -932,6 +941,11 @@ class RenderTest < ActionController::TestCase assert_equal "Goodbye, Local David", @response.body end + def test_rendering_html_only_partial_within_inline_with_js + get :render_html_only_partial_within_inline, :format => :js + assert_equal "Hello world partial with only html version", @response.body + end + def test_should_render_formatted_template get :formatted_html_erb assert_equal 'formatted html erb', @response.body diff --git a/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb b/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb new file mode 100644 index 0000000000..00e6b6d6da --- /dev/null +++ b/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb @@ -0,0 +1 @@ +partial with only html version
\ No newline at end of file |