@w0s/html-escape
v4.0.2
Published
Escapes and unescapes the characters for HTML
Downloads
819
Readme
Escapes and unescapes the characters for HTML
- Escapes and unescapes the characters for HTML
- Tagged templates (Template literals) can also be used to escape only certain parts of the string.
Examples
import { escape, unescape, template } from '@w0s/html-escape';
escape('<span data-foo="hoge&hoge">text</span>'); // <span data-foo="hoge&hoge">text</span>
unescape('<span data-foo="hoge&hoge">text</span>'); // <span data-foo="hoge&hoge">text</span>
const span = '<span>text</span>';
template`<p>${span}</p>`; // <p><span>text<span></p>