Valid XHTML is good, manually encoding your HTML entities is bad! Why the encoding is not built into the framework, I don’t know, but a simple plugin makes it easy to accomplish such a task. Install this plugin and can will be blessed with encode_entities and decode_entities.
No big deal? Well…pay particular attention to your meta description and title tags. I personally think it is good practice to encode these fields just like you’d html_escape all user controllable strings.
Installation from command line:
script/plugin install http://svn.bountysource.com/leftbee-plugins/html_helpers
or via git (will only work in edge rails, 2.02)
script/plugin install git://github.com/tma/html_helpers.git
How to use it!
1 2 3 4 5 6 7 8 | # this will encode a UTF-8 string with HTML entities # returns "Check out my resumé" <%= encode_entities("Check out my resumé") %> # decode an encoded string # returns "Check out my resumé" <%= decode_entities("Check out my resumé") %> |