Css 当给定集合为nil时呈现分部集合
给出Rails文档中的以下示例:Css 当给定集合为nil时呈现分部集合,css,ruby-on-rails,Css,Ruby On Rails,给出Rails文档中的以下示例: <%= render(partial: "ad", collection: @advertisements) || "There's no ad to be displayed" %> 我的问题是如何包装这件衣服 “没有要显示的广告” 字符串到html标记中,以便向其添加css类 比如说, <span class='text-muted'>There's no ad to be displayed</span> 没有要
<%= render(partial: "ad", collection: @advertisements) || "There's no ad to be displayed" %>
我的问题是如何包装这件衣服
“没有要显示的广告”
字符串到html标记中,以便向其添加css类
比如说,
<span class='text-muted'>There's no ad to be displayed</span>
没有要显示的广告
以下代码适用于您的情况。
这里还有一些更详细的参考资料:
<%= render(partial: "ad", collection: @advertisements) || content_tag(:span, "There's no ad to be displayed") %>