Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View rss_tag.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
class RenderRSS < Liquid::Block
 
def initialize(tag_name, markup, tokens)
super
@markup = markup
@attributes = {}
markup.scan(Liquid::TagAttributes) do |key, value|
@attributes[key] = value
end
 
RestClient.get(@attributes['source']).force_encoding('UTF-8')
@parsed_rss = SimpleRSS.parse(rss_data)
end
 
def render(context)
rss_reg = {
"title" => @parsed_rss.title,
"items" => @parsed_rss.items.map{|u| u.stringify_keys}
}
context.stack do
context['feed'] = rss_reg
render_all(@nodelist, context)
end
end
end
 
Liquid::Template.register_tag('rss', RenderRSS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.