Skip to content

Commit

Permalink
Render implicit html template when xhr request now supports localizat…
Browse files Browse the repository at this point in the history
…ion [#1886 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
josevalim authored and josh committed Feb 7, 2009
1 parent f98d8ee commit 50f51ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actionpack/lib/action_view/paths.rb
Expand Up @@ -50,6 +50,8 @@ def find_template(original_template_path, format = nil)
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}.#{I18n.locale}.html"]
return template
elsif format == :js && template = load_path["#{template_path}.html"]
return template
end
Expand Down
@@ -0,0 +1 @@
Hey HTML!
19 changes: 19 additions & 0 deletions actionpack/test/template/render_test.rb
Expand Up @@ -44,6 +44,25 @@ def test_render_file_with_dashed_locale
I18n.locale = old_locale
end

def test_render_implicit_html_template_from_xhr_request
old_format = @view.template_format
@view.template_format = :js
assert_equal "Hello HTML!", @view.render(:file => "test/render_implicit_html_template_from_xhr_request")
ensure
@view.template_format = old_format
end

def test_render_implicit_html_template_from_xhr_request_with_localization
old_locale = I18n.locale
old_format = @view.template_format
I18n.locale = :da
@view.template_format = :js
assert_equal "Hey HTML!\n", @view.render(:file => "test/render_implicit_html_template_from_xhr_request")
ensure
I18n.locale = old_locale
@view.template_format = old_format
end

def test_render_file_at_top_level
assert_equal 'Elastica', @view.render(:file => '/shared')
end
Expand Down

1 comment on commit 50f51ff

@josevalim
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Joshua! :)

Please sign in to comment.