html entities in haml
How do you write:
= link_to 'Select »', "/"
in HAML properly?
= link_to 'Select »', "/"
ju开发者_高级运维st prints »
again.
ANSWER FROM Phrogz
= link_to('Select »'.html_safe,'/')
did the trick
In the simplest test, Haml does not futz with your HTML entities:
> require "haml"
#=> true
> Haml::Engine.new('%p= "See »"').render
#=> "<p>See »</p>\n"
Your problem is probably not Haml
, but rather explicit HTML escaping with link_to
or Rails itself.
For example, see this question and also:
Ruby on Rails seems to be auto-escaping html created by link_to
If you are using Haml with Rails, perhaps try:
= raw link_to('Select »','/')
Alternatively, I would just use proper Unicode throughout your pipeline so that there is no chance that an &
will be turned into &
accidentally.
精彩评论