aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-11-18 22:01:33 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-11-18 22:01:33 +0000
commita76490d91758e775dc4facd8a3b577a60afc175e (patch)
tree90b610e47333e864d0f80e8f8ac7d7996ae610de /actionpack
parent713ca5196d9bc2f005abedf6de416a8e717e41cc (diff)
downloadrails-a76490d91758e775dc4facd8a3b577a60afc175e.tar.gz
rails-a76490d91758e775dc4facd8a3b577a60afc175e.tar.bz2
rails-a76490d91758e775dc4facd8a3b577a60afc175e.zip
Fixed that partial rendering should look at the type of the first render to determine its own type if no other clues are available (like when using text.plain.erb as the extension in AM) (closes #10130) [java] Fixed that partials would be broken when using text.plain.erb as the extension #10130 [java]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8166 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/base.rb12
2 files changed, 12 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 30367bebc0..f6d0a8be81 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that partial rendering should look at the type of the first render to determine its own type if no other clues are available (like when using text.plain.erb as the extension in AM) #10130 [java]
+
* Fixed that has_many :through associations should render as collections too #9051 [mathie/danger]
* Added :mouseover short-cut to AssetTagHelper#image_tag for doing easy image swaps #6893 [joost]
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 40d7c11509..81a8299e91 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -287,7 +287,7 @@ module ActionView #:nodoc:
raise ActionViewError, "No #{template_handler_preferences.to_sentence} template found for #{template_path} in #{view_paths.inspect}"
end
template_file_name = full_template_path(template_path, template_extension)
- template_extension = template_extension.gsub(/^\w+\./, '') # strip off any formats
+ template_extension = template_extension.gsub(/^.+\./, '') # strip off any formats
end
else
template_file_name = template_path
@@ -490,7 +490,9 @@ module ActionView #:nodoc:
# Determines the template's file extension, such as rhtml, rxml, or rjs.
def find_template_extension_for(template_path)
- find_template_extension_from_handler(template_path, true) || find_template_extension_from_handler(template_path)
+ find_template_extension_from_handler(template_path, true) ||
+ find_template_extension_from_handler(template_path) ||
+ find_template_extension_from_first_render()
end
def find_template_extension_from_handler(template_path, formatted = nil)
@@ -511,6 +513,12 @@ module ActionView #:nodoc:
end
nil
end
+
+ # Determine the template extension from the <tt>@first_render</tt> filename
+ def find_template_extension_from_first_render
+ extension = @first_render.to_s.sub /^\w+\.?/, ''
+ extension.blank? ? nil : extension
+ end
# This method reads a template file.
def read_template_file(template_path, extension)