Skip to content
Browse files

Restore implicit rendering for XHR requests that want a HTML template [

…#1590 state:resolved]
  • Loading branch information...
1 parent f17c876 commit 093f758bd05d5b6144fd06aa0606c2f987c4ee09 @josh josh committed Jan 27, 2009
View
3 actionpack/lib/action_view/paths.rb
@@ -45,6 +45,9 @@ def find_template(original_template_path, format = nil)
return template
elsif template = load_path[template_path]
return template
+ # Try to find html version if the format is javascript
+ elsif format == :js && template = load_path["#{template_path}.html"]
@josevalim
Ruby on Rails member
josevalim added a note Jan 27, 2009

You should set the contenty type to html in such cases, shouldn’t you? Otherwise it will respond as js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return template
end
end
View
8 actionpack/test/controller/render_test.rb
@@ -274,6 +274,9 @@ def render_implicit_html_template
def render_explicit_html_template
end
+ def render_implicit_html_template_from_xhr_request
+ end
+
def formatted_html_erb
end
@@ -1010,6 +1013,11 @@ def test_explicitly_rendering_an_html_template_with_implicit_html_template_rende
end
end
+ def test_should_implicitly_render_html_template_from_xhr_request
+ get :render_implicit_html_template_from_xhr_request, :format => :js
+ assert_equal "Hello HTML!", @response.body
+ end
+
def test_should_render_formatted_template
get :formatted_html_erb
assert_equal 'formatted html erb', @response.body
View
1 actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb
@@ -0,0 +1 @@
+Hello HTML!

0 comments on commit 093f758

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