假设我想在erb页面中显示如何编写erb的提示:
在helpfile.html.erb中:
Here's the right way to write a basic erb statement: <%= a = 1 %>
问题是,当这个erb文件作为rails中的视图处理时,文字erb&lt;%=会被解释,因此在显示的文件中我只看到
Here's the right way to write a basic erb statement: 1
愚蠢的问题,是吗?我该怎么做?
谢谢!
答案 0 :(得分:2)
你可以把它写成:
Here's the right way to write a basic erb statement: <%= '<%= a = 1 %>' %>
或者也许是:
Here's the right way to write a basic erb statement: <%= a = 1 %>
答案 1 :(得分:1)
尝试使用实体:
<%= Here's the right way to write a basic erb statement: 1 %>