ビュー内でフィードを呼び出して<%= blog_feed %>
おり、ヘルパーに小さなスニペットがあります。
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
def blog_feed
source = "http://www.domain.com/.rss" # url or local file
content = "" # raw content of rss feed will be loaded here
open(source) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)
html = "<ul>"
rss.items.first(3).each do |i|
html << "<li><a href='#{i.link}'>#{i.title}</a></li>"
end
html << "</ul>"
html
end
それはほとんど私が望むように実行されます。しかし、htmlはインラインhtmlです。それで、ウェブサイトにli、ul、a hrefsが表示されます。
アイデアや提案はありますか?
宜しくお願いします。