@w0s/html-escape
v3.0.0
Published
Escapes and unescapes the characters for HTML
Downloads
16
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 HtmlEscape from '@w0s/html-escape';
HtmlEscape.escape('<span data-foo="hoge&hoge">text</span>'); // <span data-foo="hoge&hoge">text</span>
HtmlEscape.unescape('<span data-foo="hoge&hoge">text</span>'); // <span data-foo="hoge&hoge">text</span>
const span = '<span>text</span>';
HtmlEscape.template`<p>${span}</p>`; // <p><span>text<span></p>
/* Short method name */
import Html from '@w0s/html-escape';
Html._('<span data-foo="hoge&hoge">text</span>');
Html.$('<span data-foo="hoge&hoge">text</span>');
const span = '<span>text</span>';
Html.__`<p>${span}</p>`;