我正在尝试这样做:
<%= <h1>Products Purchased </h1> if params[:status].nil? || params[:status] == Order.statuses[0] %>
<%= "<h1>Products Sent </h1>" if params[:status].nil? || params[:status] == Order.statuses[1] %>
感谢您的帮助。
答案 0 :(得分:6)
您需要使用.html_safe从ruby字符串输出HTML标记:
<%= "<h1>Products Sent </h1>".html_safe if params[:status].nil? || params[:status] == Order.statuses[1] %>
但你可以做到以下,更具可读性:
<% if params[:status].nil? || params[:status] == Order.statuses[1] %>
<h1>Products Sent</h1>
<% end %>