提交 2782c37b 编写于 作者: R Rick Olson

Fix #render_file so that TemplateError is called with the correct params and...

Fix #render_file so that TemplateError is called with the correct params and you don't get the WSOD.  [Rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6130 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 38e5d21b
*SVN*
# Fix #render_file so that TemplateError is called with the correct params and you don't get the WSOD. [Rick]
* Fix issue with deprecation messing up #template_root= usage. Add #prepend_view_path and #append_view_path to allow modification of a copy of the
superclass' view_paths. [Rick]
......
......@@ -245,10 +245,9 @@ def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)
# is made available as local variables.
def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc:
@first_render ||= template_path
template_path_without_extension, template_extension = path_and_extension(template_path)
if use_full_path
template_path_without_extension, template_extension = path_and_extension(template_path)
if template_extension
template_file_name = full_template_path(template_path_without_extension, template_extension)
else
......@@ -257,7 +256,6 @@ def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc
end
else
template_file_name = template_path
template_extension = template_path.split('.').last
end
template_source = nil # Don't read the source until we know that it is required
......@@ -269,7 +267,7 @@ def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc
e.sub_template_of(template_file_name)
raise e
else
raise TemplateError.new(find_base_path_for(template_file_name), template_file_name, @assigns, template_source, e)
raise TemplateError.new(find_base_path_for("#{template_path_without_extension}.#{template_extension}"), template_file_name, @assigns, template_source, e)
end
end
end
......@@ -395,6 +393,7 @@ def cached_template_extension(template_path)
@@cache_template_extensions && @@cached_template_extension[template_path]
end
# Returns the view path that contains the given relative template path.
def find_base_path_for(template_file_name)
@view_paths.find { |p| File.file?(File.join(p, template_file_name)) }
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册