gpt4 book ai didi

ruby - 如何在非 Rails 应用程序中实现 erb partials?

转载 作者:数据小太阳 更新时间:2023-10-29 06:50:01 27 4
gpt4 key购买 nike

我想做这样的事情:

require 'erb'
@var = 'test'
template = ERB.new File.new("template.erb").read
rendered = template.result(binding())

但是我怎样才能在 template.erb 中使用分音呢?

最佳答案

也许是暴力破解?

header_partial = ERB.new(File.new("header_partial.erb").read).result(binding)
footer_partial = ERB.new(File.new("footer_partial.erb").read).result(binding)

template = ERB.new <<-EOF
<%= header_partial %>
Body content...
<%= footer_partial %>
EOF
puts template.result(binding)

关于ruby - 如何在非 Rails 应用程序中实现 erb partials?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9840870/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com