提交 f3aa7c1e 编写于 作者: J Jeremy Kemper

r4730@asus: jeremy | 2006-06-29 13:13:38 -0700

 Avoid naming collision among compiled view methods. Back out AM workaround. References #5520.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4512 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 5fe64dd1
*SVN*
* Resolve conflict among mailer actions with the same name. #5520 [ssinghi@kreeti.com]
* Resolve action naming collision. #5520 [ssinghi@kreeti.com]
* ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
......
......@@ -353,7 +353,7 @@ def create!(method_name, *parameters) #:nodoc:
content_type = md.captures[1].gsub('.', '/')
@parts << Part.new(:content_type => content_type,
:disposition => "inline", :charset => charset,
:body => render_message("#{mailer_name}/#{template_name}", @body))
:body => render_message(template_name, @body))
end
unless @parts.empty?
@content_type = "multipart/alternative"
......@@ -367,7 +367,7 @@ def create!(method_name, *parameters) #:nodoc:
# it.
template_exists = @parts.empty?
template_exists ||= Dir.glob("#{template_path}/#{@template}.*").any? { |i| File.basename(i).split(".").length == 2 }
@body = render_message("#{mailer_name}/#{@template}", @body) if template_exists
@body = render_message(@template, @body) if template_exists
# Finally, if there are other message parts and a textual body exists,
# we shift it onto the front of the parts and set the body to nil (so
......@@ -432,7 +432,7 @@ def template_path
end
def initialize_template_class(assigns)
ActionView::Base.new(template_root, assigns, self)
ActionView::Base.new(template_path, assigns, self)
end
def sort_parts(parts, order = [])
......
......@@ -15,7 +15,7 @@ def file_template(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
body render(:file => "#{mailer_name}/signed_up", :body => { :recipient => recipient })
body render(:file => "signed_up", :body => { :recipient => recipient })
end
def initialize_defaults(method_name)
......
*SVN*
* Avoid naming collision among compiled view methods. [Jeremy Kemper]
* Fix CGI extensions when they expect string but get nil in Windows. Closes #5276 [mislav@nippur.irb.hr]
* Determine the correct template_root for deeply nested components. #2841 [s.brink@web.de]
......
......@@ -307,7 +307,7 @@ def compile_and_render_template(extension, template = nil, file_path = nil, loca
# Get the method name for this template and run it
method_name = @@method_names[file_path || template]
evaluate_assigns
evaluate_assigns
local_assigns = local_assigns.symbolize_keys if @@local_assigns_support_string_keys
......@@ -335,14 +335,14 @@ def erb_template_exists?(template_path)#:nodoc:
def builder_template_exists?(template_path)#:nodoc:
template_exists?(template_path, :rxml)
end
def javascript_template_exists?(template_path)#:nodoc:
template_exists?(template_path, :rjs)
end
def file_exists?(template_path)#:nodoc:
template_file_name, template_file_extension = path_and_extension(template_path)
if template_file_extension
template_exists?(template_file_name, template_file_extension)
else
......@@ -372,11 +372,11 @@ def path_and_extension(template_path)
template_path_without_extension = template_path.sub(/\.(\w+)$/, '')
[ template_path_without_extension, $1 ]
end
def cached_template_extension(template_path)
@@cache_template_extensions && @@cached_template_extension[template_path]
end
end
def find_template_extension_for(template_path)
if match = delegate_template_exists?(template_path)
match.first.to_sym
......@@ -384,7 +384,7 @@ def find_template_extension_for(template_path)
elsif builder_template_exists?(template_path): :rxml
elsif javascript_template_exists?(template_path): :rjs
else
raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path}"
raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path} in #{@base_path}"
end
end
......@@ -414,7 +414,7 @@ def supports_local_assigns?(render_symbol, local_assigns)
local_assigns.empty? ||
((args = @@template_args[render_symbol]) && local_assigns.all? { |k,_| args.has_key?(k) })
end
# Check whether compilation is necessary.
# Compile if the inline template or file has not been compiled yet.
# Or if local_assigns has a new key, which isn't supported by the compiled code yet.
......@@ -468,35 +468,21 @@ def templates_requiring_setup
%w(rxml rjs)
end
def assign_method_name(extension, template, file_name)
method_name = '_run_'
method_name << "#{extension}_" if extension
def compiled_method_name(extension, template, file_name)
['_run', extension, compiled_method_name_file_path_segment(file_name)].compact.join('_')
end
def compiled_method_name_file_path_segment(file_name)
if file_name
file_path = File.expand_path(file_name)
base_path = File.expand_path(@base_path)
i = file_path.index(base_path)
l = base_path.length
method_name_file_part = i ? file_path[i+l+1,file_path.length-l-1] : file_path.clone
method_name_file_part.sub!(/\.r(html|xml|js)$/,'')
method_name_file_part.tr!('/:-', '_')
method_name_file_part.gsub!(/[^a-zA-Z0-9_]/){|s| s[0].to_s}
method_name += method_name_file_part
File.expand_path(file_name).gsub(/[^a-zA-Z0-9_]/, '_')
else
@@inline_template_count += 1
method_name << @@inline_template_count.to_s
(@@inline_template_count += 1).to_s
end
@@method_names[file_name || template] = method_name.intern
end
def compile_template(extension, template, file_name, local_assigns)
method_key = file_name || template
render_symbol = @@method_names[method_key] || assign_method_name(extension, template, file_name)
render_symbol = @@method_names[method_key] ||= compiled_method_name(extension, template, file_name)
render_source = create_template_source(extension, template, render_symbol, local_assigns.keys)
line_offset = @@template_args[render_symbol].size
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册