Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以在 link_to 中添加 HTML 吗?
例如,而不是<%= link_to post.title, post %>我更喜欢:
<%= link_to post.title, post %>
<%= link_to '<span>post.title</span>', post %>
使用块:
<%= link_to(post) do %> <span>Test</span> <% end %>
我也会使用块,但一般方法是:
= link_to '', :href => some_path, :class=> 'some classes', :etc => 'some value' do %span your HTML here
当然,erb 也是如此。