Skip to content

Instantly share code, notes, and snippets.

@isao
Created August 22, 2012 20:41
Show Gist options
  • Save isao/3429137 to your computer and use it in GitHub Desktop.
Save isao/3429137 to your computer and use it in GitHub Desktop.
cute js version of htmlencode
//http://news.ycombinator.com/item?id=4378741
return s(val).replace(re, function(t){
if( t == '>' ) return '&gt';
if( t == '<' ) return '&lt;';
if( t == '&' ) return '&amp;';
if( t == '"' ) return '&quot;';
return t;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment