Package Exports
- escape-goat
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (escape-goat) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Escape a string for use in HTML or the inverse
Install
$ npm install escape-goat
Usage
const escapeGoat = require('escape-goat');
escapeGoat.escape('🦄 & 🐐');
//=> '🦄 & 🐐'
escapeGoat.unescape('🦄 & 🐐');
//=> '🦄 & 🐐'
escapeGoat.escape('Hello <em>World</em>');
//=> 'Hello <em>World</em>'
API
escapeGoat.escape(input)
Escapes the following characters in the given input
string: &
<
>
"
'
escapeGoat.unescape(html)
Unescapes the following HTML entities in the given input
string: &
<
>
"
'
Tip
Ensure you always quote your HTML attributes to prevent possible XSS.
FAQ
Why yet another HTML escaping package?
I couldn't find one I liked that was tiny, well-tested, and had both .escape()
and .unescape()
.
License
MIT © Sindre Sorhus