aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-04-04 21:29:50 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-04-04 21:51:45 -0300
commit797fcdf738a2a2772544731027d4fc5ca9d358bc (patch)
tree24abf7cef7e179391b7f119389bdc9aa3edb589d /actionpack/lib/action_view/helpers
parente936cf9c47e716a32b75703cb1a8badf96be8a6b (diff)
downloadrails-797fcdf738a2a2772544731027d4fc5ca9d358bc.tar.gz
rails-797fcdf738a2a2772544731027d4fc5ca9d358bc.tar.bz2
rails-797fcdf738a2a2772544731027d4fc5ca9d358bc.zip
Refactor mail_to to not generate intermediate hashes when adding href
There's no need to use Hash#merge with a new hash just for setting the href option to pass it through. Since we're always dealing with a new html_options hash, we're free to just set the value instead.
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index bfe11fc1d7..22059a0170 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -449,19 +449,20 @@ module ActionView
# <strong>Email me:</strong> <span>me@domain.com</span>
# </a>
def mail_to(email_address, name = nil, html_options = {}, &block)
- html_options, name = name, nil if block_given?
- html_options ||= {}
- html_options = html_options.stringify_keys
-
email_address = ERB::Util.html_escape(email_address)
+ html_options, name = name, nil if block_given?
+ html_options = (html_options || {}).stringify_keys
+
extras = %w{ cc bcc body subject }.map { |item|
option = html_options.delete(item) || next
"#{item}=#{Rack::Utils.escape_path(option)}"
}.compact
extras = extras.empty? ? '' : '?' + ERB::Util.html_escape(extras.join('&'))
- content_tag(:a, name || email_address.html_safe, html_options.merge("href" => "mailto:#{email_address}#{extras}".html_safe), &block)
+ html_options["href"] = "mailto:#{email_address}#{extras}".html_safe
+
+ content_tag(:a, name || email_address.html_safe, html_options, &block)
end
# True if the current request URI was generated by the given +options+.