diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-28 20:21:52 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-28 20:21:52 +0000 |
commit | 6efee90bf234328e3672bc79408c2da5b9673539 (patch) | |
tree | 1cea5008db0ae0870511647e7ebbf9ec4685bd5d /actionpack/lib/action_view | |
parent | 6b5fe9c644397ab0c3b1a1a889b3677b8f69184d (diff) | |
download | rails-6efee90bf234328e3672bc79408c2da5b9673539.tar.gz rails-6efee90bf234328e3672bc79408c2da5b9673539.tar.bz2 rails-6efee90bf234328e3672bc79408c2da5b9673539.zip |
Missing :js template falls back to :html, so you don't have to explicitly specify template format everywhere, breaking old code
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9119 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/template_finder.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/template_finder.rb b/actionpack/lib/action_view/template_finder.rb index 69832e9b4c..0fb5eaa65e 100644 --- a/actionpack/lib/action_view/template_finder.rb +++ b/actionpack/lib/action_view/template_finder.rb @@ -131,15 +131,20 @@ module ActionView #:nodoc: # # => "rhtml" # def pick_template_extension(template_path) - find_template_extension_from_handler(template_path) || find_template_extension_from_first_render + if extension = find_template_extension_from_handler(template_path, @template.template_format) || find_template_extension_from_first_render + extension + elsif @template.template_format == :js && extension = find_template_extension_from_handler(template_path, :html) + @template.template_format = :html + extension + end end - def find_template_extension_from_handler(template_path) - formatted_template_path = "#{template_path}.#{@template.template_format}" + def find_template_extension_from_handler(template_path, template_format = @template.template_format) + formatted_template_path = "#{template_path}.#{template_format}" view_paths.each do |path| if (extensions = @@file_extension_cache[path][formatted_template_path]).any? - return "#{@template.template_format}.#{extensions.first}" + return "#{template_format}.#{extensions.first}" elsif (extensions = @@file_extension_cache[path][template_path]).any? return extensions.first.to_s end |