Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 当给定集合为nil时呈现分部集合_Css_Ruby On Rails - Fatal编程技术网

Css 当给定集合为nil时呈现分部集合

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> 没有要

给出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) || content_tag(:span, "There's no ad to be displayed") %>