Permalink
Browse files

Assume html format when rendering partials in RJS. #8076 [Rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6950 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent ed1ed9e commit b83efadb32fe55ba7a7d23d650a8adc1a351eab7 @technoweenie technoweenie committed Jun 5, 2007
View
@@ -1,5 +1,7 @@
*SVN*
+* Assume html format when rendering partials in RJS. #8076 [Rick]
+
* Don't double-escape url_for in views. #8144 [Rich Collins, Josh Peek]
* Allow JSON-style values for the :with option of observe_field. Closes #8557 [kommen]
@@ -631,9 +631,13 @@ def record(line)
end
def render(*options_for_render)
+ old_format = @context && @context.template_format
+ @context.template_format = :html if @context
Hash === options_for_render.first ?
@context.render(*options_for_render) :
options_for_render.first.to_s
+ ensure
+ @context.template_format = old_format if @context
end
def javascript_object_for(object)
@@ -142,6 +142,16 @@ def partial_as_rjs
end
end
+ def respond_to_partial_as_rjs
+ respond_to do |format|
+ format.js do
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+ end
+ end
+
def rescue_action(e) raise end
private
@@ -388,6 +398,11 @@ def test_should_render_html_formatted_partial_with_rjs
assert_equal %(Element.replace("foo", "partial html");), @response.body
end
+ def test_should_render_html_formatted_partial_with_rjs_and_js_format
+ xhr :get, :respond_to_partial_as_rjs
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
+ end
+
def test_should_render_js_partial
xhr :get, :partial, :format => 'js'
assert_equal 'partial js', @response.body
@@ -15,6 +15,10 @@ class Author::Nested < Author; end
module BaseTest
+ def self.included(base)
+ base.send :attr_accessor, :template_format
+ end
+
include ActionView::Helpers::JavaScriptHelper
include ActionView::Helpers::PrototypeHelper
include ActionView::Helpers::ScriptaculousHelper

0 comments on commit b83efad

Please sign in to comment.