I have this code:
= link_to "unsubscribe instantly", "*|UNSUB|*".html_safe
That generates this HTML:
<a href="*%7CUNSUB%7C*">unsubscribe instantly</a>
The | characters are escaped. That won't work, as I'm sending this HTML to a service that is supposed to replace *|UNSUB|*
with an unsubscribe url.
Instead, I want Rails/HAML to generate this:
<a href="*|UNSUB|*">unsubscribe instantly</a>
I went to http://haml-lang.com/try.html and entered %a{:href => "*|UNSUB|*"} unsubscribe
and the output was what I was expecting. So I'm guessing this is a Rails thing.
UPDATE: I tried this on a new Rails 3.1 application and the pipes aren't being escaped -- which is what I wanted. There's something weird happening with my main rails application that's causing the URLs to be escaped -- looking into it further now.
UPDATE: I figured it out. I had some Rack middleware that was running something like:
content = Nokogiri(response)
# ... processing
return content.to_html
This was encoding the stuff inside the URLs. I asked a related question here: Preventing Nokogiri from escaping characters in URLs