This release is a pre-release — the latest non-prerelease version of @thai/html is 0.0.5. Jump to this version
Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
Safely generate HTML strings
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
JSR Score
100%
Published
2 months ago (0.1.0-alpha.0)
The @thai/html
package provides the html
tagged template function
that can be used to safely generate HTML code.
Usage
import { html, renderHtml } from "@thai/html"; // Strings are escaped console.log(renderHtml("<>")); // "<>" // Numbers and booleans are converted to strings console.log(renderHtml(42)); // "42" console.log(renderHtml(true)); // "true" // HTML code can be generated using the `html` tagged template function console.log(renderHtml(html`<b>${"<>"}</b>`)); // "<b><></b>" // Arrays are concatenated console.log(renderHtml(["one", "two", "three"])); // "onetwothree" // `null` and `undefined` are converted to an empty string console.log(renderHtml(html`${null}`)); // ""
Built and signed on
View transparency logGitHub Actions
Add Package
deno add jsr:@thai/html
Import symbol
import * as mod from "@thai/html";
---- OR ----
Import directly with a jsr specifier
import * as mod from "jsr:@thai/html";
Add Package
npx jsr add @thai/html
Import symbol
import * as mod from "@thai/html";
Add Package
yarn dlx jsr add @thai/html
Import symbol
import * as mod from "@thai/html";
Add Package
pnpm dlx jsr add @thai/html
Import symbol
import * as mod from "@thai/html";
Add Package
bunx jsr add @thai/html
Import symbol
import * as mod from "@thai/html";