我正在嘗試在液體佈局(Liquid Template lang,不是CSS液體佈局的東西)內渲染液體模板。我似乎無法得到佈局部分呈現。目前正在使用:如何使用Liquid模板語言在佈局中渲染模板?
assigns = {'page_name' => 'test'}
@layout = Liquid::Template.parse(File.new(@theme.layout.path).read)
@template = Liquid::Template.parse(File.new(self.template.path).read)
@rend_temp = @template.render(assigns)
@rend_layout = @layout.render({'content_for_layout' => @rend_temp})
render :text => @rend_layout, :content_type => :html
產生的頁面的HTML顯示,「模板」呈現在液體很好,但它不與佈局包裹(與渲染的模板替換「content_for_layout」佈局)
是的,但有模板查找和你從你上面的代碼放棄繼承鐵軌其他東西的一些劫持。雖然它起作用,但它的風格或功能並不完全是「rails-ish」。 – Dan 2013-03-26 18:22:14