From 50f51ff95047858fa6dd889ade3027b7254c6dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 7 Feb 2009 11:37:02 -0600 Subject: Render implicit html template when xhr request now supports localization [#1886 state:resolved] Signed-off-by: Joshua Peek --- actionpack/lib/action_view/paths.rb | 2 ++ ...mplicit_html_template_from_xhr_request.da.html.erb | 1 + actionpack/test/template/render_test.rb | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb (limited to 'actionpack') diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index c7d6fd696a..b487bd1aa7 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -50,6 +50,8 @@ module ActionView #:nodoc: 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 diff --git a/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb b/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb new file mode 100644 index 0000000000..0740b2d07c --- /dev/null +++ b/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb @@ -0,0 +1 @@ +Hey HTML! diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 5586434cb6..9db62d9c23 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -44,6 +44,25 @@ module RenderTestCases 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 -- cgit v1.2.3