我看过关于如何添加 <span>
的 SO标签,但我没有看到放置 <span>
的示例我想在哪里使用 Rails 3 link_to
:
<a href="#" class="button white"><span id="span">My span </span>My data</a>
我试过类似的方法:
<%= link_to(content_tag{:span => "My span ", :id => "span"} @user.profile.my_data, "#", {:class => "button white"}) %>
但这没有用。
最佳答案
link_to
can take a block所以我认为您正在寻找这样的东西:
<%= link_to '#', :class => 'button white' do %>
<span id="span">My span </span><%= @user.profile.my_data %>
<% end %>
关于html - 在 Rails link_to 中添加 span 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7563911/