使ERB.run安静

时间:2011-03-03 17:42:53

标签: ruby ruby-on-rails-3 erb

我在Rails应用程序中使用ERB来呈现ERB模板,类似于......

T = ERB.new(...)
result = T.run(....)

但是我在终端中注意到ERB正在将转换(从erb模板转换为填充文本)转发到终端。如何让ERB保持安静?

1 个答案:

答案 0 :(得分:0)

我能够做到这一点:

T = ERB.new(...)
file = open('some-new-file.html','w')
file.write T.result(binding) # where binding is the thing that has the data