Skip to content

Instantly share code, notes, and snippets.

@zachad
Created July 16, 2013 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachad/6005528 to your computer and use it in GitHub Desktop.
Save zachad/6005528 to your computer and use it in GitHub Desktop.
One way to safely escape HTML when writing out JSON objects
<script type='text/javascript'>
var Search = <%= @search.to_json.gsub("/", "\/") %>;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment