diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-12 01:56:55 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-12 01:56:55 +0000 |
commit | 6e3e5cadfbd7db407364bf2571a5003cf3733480 (patch) | |
tree | cee5b1b08e026a7a7e679fdf5b7d42236f9eea07 /actionpack/lib | |
parent | 8e8b6b9e403cdeb57d0ba373bff6498dc7f9f5df (diff) | |
download | rails-6e3e5cadfbd7db407364bf2571a5003cf3733480.tar.gz rails-6e3e5cadfbd7db407364bf2571a5003cf3733480.tar.bz2 rails-6e3e5cadfbd7db407364bf2571a5003cf3733480.zip |
Added option to render action/template/file of a specific extension (and here by template type). This means you can have multiple templates with the same name but a different extension [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3841 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/mime_responds.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb index 7a60a5cc37..42b6e24205 100644 --- a/actionpack/lib/action_controller/mime_responds.rb +++ b/actionpack/lib/action_controller/mime_responds.rb @@ -50,4 +50,4 @@ module ActionController #:nodoc: end end end -end +end
\ No newline at end of file diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 2f0eaf367c..d2f4764575 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -216,8 +216,14 @@ module ActionView #:nodoc: @first_render = template_path if @first_render.nil? if use_full_path - template_extension = pick_template_extension(template_path) - template_file_name = full_template_path(template_path, template_extension) + template_path_without_extension, template_extension = template_path.split('.') + + if template_extension + template_file_name = full_template_path(template_path_without_extension, template_extension) + else + template_extension = pick_template_extension(template_path) + template_file_name = full_template_path(template_path, template_extension) + end else template_file_name = template_path template_extension = template_path.split('.').last @@ -324,8 +330,14 @@ module ActionView #:nodoc: end def file_exists?(template_path)#:nodoc: - %w(erb builder javascript delegate).any? do |template_type| - send("#{template_type}_template_exists?", template_path) + template_file_name, template_file_extension = template_path.split(".") + + if template_file_extension + template_exists?(template_file_name, template_file_extension) + else + %w(erb builder javascript delegate).any? do |template_type| + send("#{template_type}_template_exists?", template_path) + end end end |