html
HTML escape/unescape inspired by html and html template literal inspired by lit-html
.
escape
Escape five html entities: <, >, &, ' and ".
import { escape } from "https://deno.land/x/html_escape@v1.1.3/escape.ts";
console.log(escape(`"Fran & Freddie's Diner" <tasty@example.com>`));
// "Fran & Freddie's Diner" <tasty@example.com>
unescape
Unescape html entities to characters.
import { unescape } from "https://deno.land/x/html_escape@v1.1.3/unescape.ts";
console.log(unescape(""Fran & Freddie's Diner" <tasty@example.com>"));
// "Fran & Freddie's Diner" <tasty@example.com>
html
Template literal to safely embed values inside html fragments.
import { html } from "https://deno.land/x/html_escape@v1.1.3/html.ts";
const list = ["one", "with", `"escaping"`];
function li(value: string) {
return html`<li>${value}</li>`;
}
const body = html`<ul>${list.map(li)}</ul>`;
console.log(body.toString());
// <ul><li>one</li><li>with</li><li>"escaping"</li></ul>