如何将erb转换为html? [英] How can I convert erb to html?
本文介绍了如何将erb转换为html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想象一下,我有 @template
是 ActionTemplate :: View
的实例。
Imagine in rails I have @template
that is an instance of ActionTemplate::View
.
问题是:如何转换其@ template.source为<%=的
到 @template
来自erb的问好%> 来自erb的你好
?谢谢
Question is: How can I convert @template
whose @template.source is <%= "hello from erb" %>
to hello from erb
?? thanks
推荐答案
尝试一下...
ERB.new(@template.source).result
这篇关于如何将erb转换为html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文