Builderを使いたい
ただcampingのview部分がmarkabyデフォルトで、htmlおよびxhtml以外のレンダリングをする場合にはちょっとした工夫が必要みたいだったので、ためしにBuilderを使ってRSSを書いてみた。
ちなみに「uke rss at camping」とか書いて思い出したんだけど、昔富士五湖にキャンプに行ったときに寒いからという理由で日本酒と鮭のハラスを大量に摂取し、寝袋の中でゲロを吐いたのを思い出した。
%w[rubygems camping builder].each{|x| require x} Camping.goes :App module App def render_rss(contents) Builder::XmlMarkup.new(:indent => 2).instance_eval do instruct! :xml, :version => "1.0", :encoding => "UTF-8" rss :version => "2.0" do channel do title "uke rss at camping"; description "'render_rss' method test"; link "http://xxx.xxx.com/"; for content in contents item {title content[:title];description content[:body]} end end end end end end module App::Controllers class Feed < R '/feed' def get @headers["Content-Type"] = "text/xml; charset=utf-8" @contents = [{:title => "1st", :body => "this is first"},{:title => "2nd", :body => "this is second"}] render_rss @contents end end class Html < R '/html' def get @contents = [{:title => "1st", :body => "this is first"},{:title => "2nd", :body => "this is second"}] render :hypertext end end end module App::Views def hypertext html do head{title "this is html"} body{ for content in @contents h3 content[:title] p content[:body] end } end end end
おもいっきり↓これに影響されてる!!
http://redhanded.hobix.com/inspect/randomNumberInAFeedForPipesMaybe.html
%w[rubygems camping builder].each{|x| require x}
とか超かっこいいんですけどー