aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-02-07 11:37:02 -0600
committerJoshua Peek <josh@joshpeek.com>2009-02-07 11:37:02 -0600
commit50f51ff95047858fa6dd889ade3027b7254c6dc0 (patch)
tree9a1c5e4d174ce5180eff33dcaaca14891833d525
parentf98d8ee72b2fd92bf0e09f3cade60add9efd3a15 (diff)
downloadrails-50f51ff95047858fa6dd889ade3027b7254c6dc0.tar.gz
rails-50f51ff95047858fa6dd889ade3027b7254c6dc0.tar.bz2
rails-50f51ff95047858fa6dd889ade3027b7254c6dc0.zip
Render implicit html template when xhr request now supports localization [#1886 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
-rw-r--r--actionpack/lib/action_view/paths.rb2
-rw-r--r--actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb1
-rw-r--r--actionpack/test/template/render_test.rb19
3 files changed, 22 insertions, 0 deletions
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