【发布时间】:2013-02-17 12:41:57
【问题描述】:
我在将数据传递给 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
我的问题是在我的情况下如何将参数传递给布局模板?
【问题讨论】:
-
所以不能调用最后一个渲染wir选项?喜欢
l.render(Object.new, :my_title => 'bla') { _p }