orioltf
6/11/2012 - 12:06 PM

#HAML #ERB: Sanitize text in Rails / Sinatra

#HAML #ERB: Sanitize text in Rails / Sinatra

<!-- To sanitize text or escape special characters (ampersand for instance), use the method h() -->

<% link_to(h(url), url) %>
<% link_to(h('Help & Support'), './help.html') %> <!-- OUTPUT: <a href="../help.html">Help &amp; Support</a> -->


<!-- Credit goes to Ville: http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to#418-Remember-to-sanitize-name -->