Method: Padrino::Helpers::AssetTagHelpers#feed_tag

Defined in:
padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb

#feed_tag(mime, url, options = {}) ⇒ String

Creates a link tag that browsers and news readers can use to auto-detect an RSS or ATOM feed.

@param options

The options for the feed tag.

Examples:

feed_tag :atom, url(:blog, :posts, :format => :atom), :title => "ATOM"
# Generates: <link type="application/atom+xml" rel="alternate" href="/blog/posts.atom" title="ATOM" />
feed_tag :rss, url(:blog, :posts, :format => :rss)
# Generates: <link type="application/rss+xml" rel="alternate" href="/blog/posts.rss" title="rss" />

Parameters:

  • mime (Symbol)

    The mime type of the feed (i.e :atom or :rss).

  • url (String)

    The url for the feed tag to reference.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :rel (String) — default: "alternate"

    Specify the relation of this link.

  • :type (String)

    Override the auto-generated mime type.

  • :title (String)

    Specify the title of the link, defaults to the type.

Returns:

  • (String)

    Feed link html tag with specified options.

[View source] [View on GitHub]

117
118
119
120
# File 'padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb', line 117

def feed_tag(mime, url, options={})
  full_mime = (mime == :atom) ? 'application/atom+xml' : 'application/rss+xml'
  tag(:link, { :rel => 'alternate', :type => full_mime, :title => mime, :href => url }.update(options))
end