Reputation: 447
Can I add HTML in a link_to?
For example, instead of <%= link_to post.title, post %>
I'd prefer:
<%= link_to '<span>post.title</span>', post %>
Upvotes: 0
Views: 733
Reputation: 331
I would use block as well but general approach is:
= link_to '', :href => some_path, :class=> 'some classes', :etc => 'some value' do
%span your HTML here
The same in erb of course.
Upvotes: 0
Reputation: 2016
Use block:
<%= link_to(post) do %>
<span>Test</span>
<% end %>
Upvotes: 2