0

我如何给 #{self.o_cord.name} 和 #{self.o_product.full_name} 一个内联样式,使其背景颜色变为橙色?它们在一个 .rb 文件中,我不确定这是否会改变任何东西。提前致谢!

if self.o_connection.dongle? 
  return "Plug the #{self.o_cord.name} end of the #{self.o_product.full_name} into the #{self.i_product.full_name}."
4

2 回答 2

0

Haml 内联 css 示例:

= f.text_area :short_description, :style =>'background-color:'orange';'

erb

<%= f.text_field :short_description, :style => 'background-color:'orange';' %>
于 2013-08-17T05:20:40.973 回答
0

我会将字符串排除在您的模型之外,而是调用 o_connection.dongle? 从你的角度来看。然后在您看来,您可以简单地通过 css 将关键字包装在 span 和 style 中。

看法:

<% if SomeClass.o_connection.dongle? %>
  <p>Plug the <span class="info-label"><%= self.o_cord.name %></span> end of the <span class="info-label"><%= self.o_product.full_name %></span class="info-label"> into the <span><%= self.i_product.full_name %></span>.</p> 

CSS:

span.info-label {
  background-color: 'orange';
}
于 2013-08-17T00:40:34.923 回答