Added tag_options as a third parameter to AssetHelper#auto_discovery_link_tag to control options like the title of the link #1430 [kevin.clark@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1460 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
f2a021dc06
commit
bc6570dfcb
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Added tag_options as a third parameter to AssetHelper#auto_discovery_link_tag to control options like the title of the link #1430 [kevin.clark@gmail.com]
|
||||
|
||||
* Added option to pass in parameters to CaptureHelper#capture, so you can create more advanced view helper methods #1466 [duane.johnson@gmail.com]. Example:
|
||||
|
||||
<% show_calendar(:year => 2005, :month => 6) do |day, options| %>
|
||||
|
|
|
@ -14,11 +14,16 @@ module ActionView
|
|||
# <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.curenthost.com/controller/action" />
|
||||
# auto_discovery_link_tag(:atom) # =>
|
||||
# <link rel="alternate" type="application/atom+xml" title="ATOM" href="http://www.curenthost.com/controller/action" />
|
||||
# auto_discovery_link_tag(:rss, :action => "feed") # =>
|
||||
# <link rel="alternate" type="application/atom+xml" title="ATOM" href="http://www.curenthost.com/controller/feed" />
|
||||
def auto_discovery_link_tag(type = :rss, options = {})
|
||||
# auto_discovery_link_tag(:rss, {:action => "feed"}) # =>
|
||||
# <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.curenthost.com/controller/feed" />
|
||||
# auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"}) # =>
|
||||
# <link rel="alternate" type="application/rss+xml" title="My RSS" href="http://www.curenthost.com/controller/feed" />
|
||||
def auto_discovery_link_tag(type = :rss, options = {}, tag_options = {})
|
||||
tag(
|
||||
"link", "rel" => "alternate", "type" => "application/#{type}+xml", "title" => type.to_s.upcase,
|
||||
"link",
|
||||
"rel" => tag_options[:rel] || "alternate",
|
||||
"type" => tag_options[:type] || "application/#{type}+xml",
|
||||
"title" => tag_options[:title] || type.to_s.upcase,
|
||||
"href" => url_for(options.merge(:only_path => false))
|
||||
)
|
||||
end
|
||||
|
|
|
@ -27,6 +27,12 @@ class AssetTagHelperTest < Test::Unit::TestCase
|
|||
%(auto_discovery_link_tag) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />),
|
||||
%(auto_discovery_link_tag(:atom)) => %(<link href="http://www.example.com" rel="alternate" title="ATOM" type="application/atom+xml" />),
|
||||
%(auto_discovery_link_tag(:rss, :action => "feed")) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />),
|
||||
%(auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />),
|
||||
%(auto_discovery_link_tag(:rss, {}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />),
|
||||
%(auto_discovery_link_tag(nil, {}, {:type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="" type="text/html" />),
|
||||
%(auto_discovery_link_tag(nil, {}, {:title => "No stream.. really", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="No stream.. really" type="text/html" />),
|
||||
%(auto_discovery_link_tag(:rss, {}, {:title => "My RSS", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="text/html" />),
|
||||
%(auto_discovery_link_tag(:atom, {}, {:rel => "Not so alternate"})) => %(<link href="http://www.example.com" rel="Not so alternate" title="ATOM" type="application/atom+xml" />),
|
||||
}
|
||||
|
||||
JavascriptPathToTag = {
|
||||
|
|
Loading…
Reference in New Issue