为什么ERB独立渲染不能用于实例变量?那是“<%= @test_var%>”行的输出为空?为什么ERB独立渲染不能用于实例变量
@test_var = "test variable"
template = Tilt.new('./app/scripts/email.erb')
st = template.render
puts st
和email.erb
<html>
<body>
<h1>This is it!</h1>
<p>
Phone Number: <%= @test_var %>
</p>
</body>
</html>
给
<html>
<body>
<h1>This is it!</h1>
<p>
Phone Number:
</p>
</body>
</html>
为我工作,你也可以省略函数get_binding并直接传递绑定。我想把字符串作为html,所以我做了'html = rhtml.result(binding)' – portforwardpodcast 2013-06-02 22:57:56