safe-html-strings
v1.0.1
Published
Safe HTML template strings with automatic escaping.
Maintainers
Readme
safe-html-strings
Safe HTML template strings with automatic escaping.
Installation
npm install safe-html-stringsUsage
import { safeHtml } from "safe-html-strings";
const userInput = '<img src=x onerror="alert(1)">';
const html = safeHtml`<p>${userInput}</p>`;
console.log(html);
// <p><img src=x onerror="alert(1)"></p>The rawHtml function is also available for inserting trusted HTML.
