动态 CSS 生成在 Rails4 中不起作用 [英] Dynamic CSS generation doesn't work in Rails4
本文介绍了动态 CSS 生成在 Rails4 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码不起作用,我需要根据 tale.id 的 vale 创建 css 类,如read-more-105"、read-more-106"等
The following code isn't working, I need to create css class like 'read-more-105','read-more-106' etc, according to tale.id's vale
<%= simple_format truncate(plot.description, length: char_counter){link_to "Read More",'', class: 'read-more-<% tale.id %>'} %>
推荐答案
你需要在这里进行字符串插值:
you need string interpolation here:
<%= simple_format truncate(plot.description, length: char_counter){link_to "Read More",'', class: "read-more-#{tale.id}" } %>
因为您不能在 <% %>
或 <%= %>
中包含 <% %>
>.
As you can not have <% %>
inside a <% %>
or <%= %>
.
这篇关于动态 CSS 生成在 Rails4 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文