Class: RenderRSS

Inherits:
Liquid::Block
  • Object
show all
Defined in:
app/liquid/blocks/rss.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ RenderRSS

Returns a new instance of RenderRSS.



3
4
5
6
7
8
9
10
11
12
13
# File 'app/liquid/blocks/rss.rb', line 3

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

Instance Method Details

#render(context) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'app/liquid/blocks/rss.rb', line 15

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