Oma*_*shi 46
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-concat
应该是你在寻找什么.
例如以下声明使用concat
:
<% concat "Output" %>
Run Code Online (Sandbox Code Playgroud)
相当于:
<%= "Output" %>
Run Code Online (Sandbox Code Playgroud)
在ERB中:<%%>表示此处有Ruby代码需要解释.<%=%>表示输出ruby代码,即显示/打印结果.
因此,如果要在标准ERB文件中输出,似乎需要使用extra =符号.
否则,您可以查看ERB的替代方法,这需要更少的语法,...也许尝试类似HAML的东西.http://haml-lang.com/tutorial.html
Example:
# ERB
<strong><%= item.title %></strong>
# HAML
%strong= item.title
Run Code Online (Sandbox Code Playgroud)
那更方便吗?