Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded HTML in link_to body in Rails

What is the best way to go about getting embedded HTML in the body of a link generated with the link_to method?

I basically want the following:

<a href="##">This is a <strong>link</strong></a> 

I have been trying to go about this as suggested in Rails and the <span> tag but with no luck. My code looks like the following:

item_helper.rb

def picture_filter     #...Some other code up here     text = "Show items with " + content_tag(:strong, 'pictures')     link_to text, {:pics => true}, :class => 'highlight' end 

item_view.html.erb

 #...  <%=raw picture_filter %>  #... 
like image 784
Ryan Avatar asked Mar 15 '11 20:03

Ryan


1 Answers

Try it this way

<%= link_to(raw("a <strong>strong</strong> link"),{:pics => true},{ :class => 'highlight'})  %> 
like image 57
Valdis Avatar answered Oct 02 '22 07:10

Valdis