Reputation: 2835
Everytime I am trying to combine a string with a link_to it is outputting in my browser as escaped HTML.
eg.
%(TEST #{link_to(object.title, object)})
OUTPUTS
TEST <a href="/objects/3">TEST OBJECT</a>
Why is this happening ? Every example I see on net the link_to does not get escaped.
Upvotes: 3
Views: 4957
Reputation: 147
This also do the job:
<%=raw %(TEST #{link_to(object.title, object)}) %>
Upvotes: 4
Reputation: 43318
Output is escaped by default in Rails 3. If you append .html_safe
to your string it will do what you expect.
%(TEST #{link_to(object.title, object)}).html_safe
Upvotes: 12