Skip to content

Instantly share code, notes, and snippets.

@orioltf
Created June 11, 2012 12:06
Show Gist options
  • Save orioltf/2909791 to your computer and use it in GitHub Desktop.
Save orioltf/2909791 to your computer and use it in GitHub Desktop.
#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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment