将数据传递给Slim模板时遇到问题。我有以下工作代码(使用来自this SO thread的信息):
l = Slim::Template.new { @layout } # How to pass data here?
_p = Slim::Template.new { @post_text }.render(Object.new, :post => post)
# Here passing data (post) works fine -----------------^
out = l.render{ _p }
我在模板中有什么:
layout.slim :
doctype
html
head
title =my_title # < I cannot pass any parameters to this file
body
==yield
post_text.slim :
-unless post.nil?
h1 =post[:title]
hr
=post[:text]
-else
h2 No posts
我的问题是如何在我的情况下将参数传递给布局模板?