Skip to content

Instantly share code, notes, and snippets.

@danielcooper
Created July 15, 2012 21:57
Show Gist options
  • Save danielcooper/3118852 to your computer and use it in GitHub Desktop.
Save danielcooper/3118852 to your computer and use it in GitHub Desktop.
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