Suppress HTML escaping in link_to(:title)?


#1

Hi guys,

I’m new to this list and it seems you are my last hope.

How can I prevent Rails from automatically escaping HTML entities when
creating a hyperlink?

You know, link_to( … :title => ‘This is „quoted“’) returns
‘This is „quoted“’ because Rails escapes the ampersands to
&.

Is there a way I can stop/alter this behaviour so I can use these
numeric references in my title tag?

Kind regards

.mitro


#2

2006/1/20, Trojanek Michael M. removed_email_address@domain.invalid:

Is there a way I can stop/alter this behaviour so I can use these
numeric references in my title tag?

I think the easiest way would be to write out the link by hand, using
url_for instead of link_to.

Something like: <a href=<%= url_for … %> title="<%=@title%>" />

Though I think you have a bug somewhere else. Why do you have escaped
HTML stored as data? Are you escaping input? (a bad idea)

The only reason I can think of at the moment to store escaped HTML
would be as a caching thing, perhaps you could use the built in Rails
caching?

Douglas