Sha256: 7271b0000f4d1d034182b6c7bf1583ba2bdb7de15aebb5fdfe3d4f8f36bdfcbd

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Fullstack
  module Rss
    module Helpers
      extend ActiveSupport::Concern
        
      included do
        helper_method :rss_feed_link
      end
      
      # eg.
      # render_feed( @items, 
      #     title:        @feed_title,
      #     link:         root_url,
      #     description:  "This is a great feed.",
      #     language:     "en"
      # )
      
      def render_feed(items, options = {})
        render :template => "fullstack/rss/feed.xml.erb", :locals => { :items => items, :options => options }
      end
      
      protected
    
      # This is just a little helper to link feeds.
      #
      # usage:
      # <%= rss_feed_link site_feed_path, :title => "Intresting stuffs from my blog" %>
      #
      
      def rss_feed_link(url, options = {})
        title = options.delete(:title)
        raise ":title option is required" if !title
        title = view_context.h(title)
      
        "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{title}\" href=\"#{url}\" />"
      end
      
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fullstack-rss-0.1.2 lib/fullstack/rss/helpers.rb
fullstack-rss-0.1.1 lib/fullstack/rss/helpers.rb