将 <% 作为文字放入 .erb 文件中



假设我想在 erb 页面中显示有关如何编写 erb 的提示:

在帮助文件.html.erb 中:

Here's the right way to write a basic erb statement: <%= a = 1 %>

问题是,当该 erb 文件在 rails 中作为视图处理时,文字 erb <%=被解释,因此在显示的文件中我只看到

Here's the right way to write a basic erb statement: 1

我该怎么做?

你可以

把它写成:

Here's the right way to write a basic erb statement: <%= '<%= a = 1 %>' %>

或者也许是:

Here's the right way to write a basic erb statement: &lt;%= a = 1 %&gt;

尝试使用实体:

<&#37;= Here's the right way to write a basic erb statement: 1 &#37;>

相关内容

  • 没有找到相关文章

最新更新