diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-05 00:38:09 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-05 00:38:09 +0000 |
commit | efe0348486aee9b19877e730a6a07db9c717f2f2 (patch) | |
tree | 7c7fd7eed5152e056b8a30bb5e9ea9b5db6a123f /actionpack/lib/action_view | |
parent | f92ae75a23cddbdc6e55fc17dcf5052fba330c75 (diff) | |
download | rails-efe0348486aee9b19877e730a6a07db9c717f2f2.tar.gz rails-efe0348486aee9b19877e730a6a07db9c717f2f2.tar.bz2 rails-efe0348486aee9b19877e730a6a07db9c717f2f2.zip |
Added the possibility of passing nil to UrlHelper#link_to to use the link itself as the name
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@338 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/url_helper.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 098fce8100..0113c42eb7 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -13,15 +13,18 @@ module ActionView # Creates a link tag of the given +name+ using an URL created by the set of +options+. See the valid options in # link:classes/ActionController/Base.html#M000021. It's also possible to pass a string instead of an options hash to - # get a link tag that just points without consideration. The html_options have a special feature for creating javascript - # confirm alerts where if you pass :confirm => 'Are you sure?', the link will be guarded with a JS popup asking that question. - # If the user accepts, the link is processed, otherwise not. + # get a link tag that just points without consideration. If nil is passed as a name, the link itself will become the name. + # The html_options have a special feature for creating javascript confirm alerts where if you pass :confirm => 'Are you sure?', + # the link will be guarded with a JS popup asking that question. If the user accepts, the link is processed, otherwise not. def link_to(name, options = {}, html_options = {}, *parameters_for_method_reference) convert_confirm_option_to_javascript!(html_options) unless html_options.nil? if options.is_a?(String) - content_tag "a", name, (html_options || {}).merge({ "href" => options }) + content_tag "a", name || options, (html_options || {}).merge({ "href" => options }) else - content_tag("a", name, (html_options || {}).merge({ "href" => url_for(options, *parameters_for_method_reference) })) + content_tag( + "a", name || url_for(options, *parameters_for_method_reference), + (html_options || {}).merge({ "href" => url_for(options, *parameters_for_method_reference) }) + ) end end |