aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-04-19 18:52:14 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-04-19 18:59:13 +0100
commitef4c65088fb907fc819e6b5d83d284c38cdaabfc (patch)
treee4e674e270a04a71deb0aa5741ae6c4f16b847db /actionpack/lib/action_view
parent534c6b2444970d59aea654aa3c6aeb41c206d14d (diff)
downloadrails-ef4c65088fb907fc819e6b5d83d284c38cdaabfc.tar.gz
rails-ef4c65088fb907fc819e6b5d83d284c38cdaabfc.tar.bz2
rails-ef4c65088fb907fc819e6b5d83d284c38cdaabfc.zip
Move missing template logic to ActionView
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/base.rb3
-rw-r--r--actionpack/lib/action_view/template.rb16
2 files changed, 13 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index f001b81eca..e57c447682 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -1,6 +1,9 @@
module ActionView #:nodoc:
class ActionViewError < StandardError #:nodoc:
end
+
+ class MissingTemplate < ActionViewError #:nodoc:
+ end
# Action View templates can be written in three ways. If the template file has a +.erb+ (or +.rhtml+) extension then it uses a mixture of ERb
# (included in Ruby) and HTML. If the template file has a +.builder+ (or +.rxml+) extension then Jim Weirich's Builder::XmlMarkup library is used.
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 985aa090e5..bc3d8d5e52 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -54,9 +54,8 @@ module ActionView #:nodoc:
@filename = @finder.pick_template(@path_without_extension, @extension)
else
@extension = @finder.pick_template_extension(@path).to_s
- unless @extension
- raise ActionViewError, "No template found for #{@path} in #{@finder.view_paths.inspect}"
- end
+ raise_missing_template_exception unless @extension
+
@filename = @finder.pick_template(@path, @extension)
@extension = @extension.gsub(/^.+\./, '') # strip off any formats
end
@@ -64,9 +63,14 @@ module ActionView #:nodoc:
@filename = @path
end
- if @filename.blank?
- raise ActionViewError, "Couldn't find template file for #{@path} in #{@finder.view_paths.inspect}"
- end
+ raise_missing_template_exception if @filename.blank?
+ end
+
+ def raise_missing_template_exception
+ full_template_path = @path.include?('.') ? @path : "#{@path}.#{@view.template_format}.erb"
+ display_paths = @finder.view_paths.join(':')
+ template_type = (@path =~ /layouts/i) ? 'layout' : 'template'
+ raise(MissingTemplate, "Missing #{template_type} #{full_template_path} in view path #{display_paths}")
end
# Template Handlers