【发布时间】:2012-05-30 20:54:08
【问题描述】:
在过去的 2 周里,我遇到了以下困扰我的问题:
我想用预渲染的 html-body 创建报告:
def new
@content_for_prerendering= Report.get_content
@report = Report.new
template = ERB.new(File.read("#{Rails.root}/app/views/report_template/default.html.erb"))
@report.body = template.result(binding)
end
遵循 ERB 文档。但在模板文件 DEFAULT.HTML.ERB 中,我似乎只能看到像
这样的局部变量 content_for_prerendering = Report.get_content
不是实例变量。将每个实例变量绑定到本地只是为了呈现一些 html 是非常不寻常的。我错过了什么吗?
【问题讨论】:
标签: ruby-on-rails erb