2010-03-17 59 views
0

我想使用一個自定義模板文件,它使用Rails金屬代碼中的基本佈局文件(app/view/layouts/application.html.erb)。有人可以給我一些提示,我需要什麼或我該怎麼做?如何在導軌金屬中渲染?

回答

2
require 'erb' 
class Poller # in metal 
    def self.call(env) 
    # can find abs path using File.dirname(__FILE__)/../app/... 
    view = IO.read(`/absolute/path/app/view/layouts/application.html.erb`) 
    template = ERB.new(view) 
    body = template.result(binding) 
    [200, {"Content-Type" => "text/html"}, body] 
    end 
end 
+0

非常感謝你:) – xaver23 2010-03-17 09:46:34