UNPKG

hytypemedia

Version:

Minimal typed HTML templating helpers for Hono/Workers/HTMX. JSX-free, type-safe HTML generation with automatic escaping.

31 lines 9.13 kB
type ClassValue = string | string[] | Record<string, boolean>; type StyleValue = string | Record<string, string | number>; type Content = string | number | boolean | null | undefined | SafeHtml | (string | number | boolean | null | undefined | SafeHtml)[]; type GlobalAttrs = { id?: string; class?: ClassValue; style?: StyleValue; role?: string; tabindex?: number; title?: string; [k: `data-${string}`]: unknown; [k: `aria-${string}`]: unknown; } & Record<string, unknown>; type SafeHtml = { __raw: string; }; export declare const raw: (html: string) => SafeHtml; declare const elements: { [k: string]: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml; }; export declare const a: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, abbr: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, address: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, area: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, article: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, aside: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, audio: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, b: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, base: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, bdi: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, bdo: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, blockquote: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, body: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, br: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, button: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, canvas: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, caption: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, cite: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, code: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, col: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, colgroup: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, data: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, datalist: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, dd: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, del: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, details: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, dfn: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, dialog: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, div: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, dl: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, dt: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, em: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, embed: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, fieldset: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, figcaption: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, figure: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, footer: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, form: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, h1: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, h2: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, h3: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, h4: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, h5: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, h6: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, head: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, header: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, hr: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, html: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, i: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, iframe: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, img: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, input: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, ins: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, kbd: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, label: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, legend: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, li: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, link: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, main: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, map: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, mark: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, meta: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, meter: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, nav: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, noscript: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, object: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, ol: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, optgroup: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, option: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, output: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, p: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, picture: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, pre: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, progress: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, q: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, rp: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, rt: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, ruby: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, s: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, samp: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, script: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, section: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, select: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, slot: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, small: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, source: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, span: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, strong: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, style: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, sub: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, summary: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, sup: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, svg: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, table: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, tbody: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, td: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, template: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, text: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, textarea: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, tfoot: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, th: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, thead: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, time: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, title: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, tr: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, track: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, u: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, ul: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, var_: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, video: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml, wbr: (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml; export default elements; export declare const Fragment: (...children: Content[]) => SafeHtml; export declare const doctype: () => SafeHtml; export declare const safeText: (s: string | number | boolean | null | undefined) => string; export declare const toString: (html: SafeHtml) => string; export type HtmlFunction = (...args: [GlobalAttrs, ...Content[]] | Content[]) => SafeHtml; export type Elements = typeof elements; export type { GlobalAttrs, ClassValue, StyleValue, Content, SafeHtml }; export declare function customElement(tagName: string): HtmlFunction; //# sourceMappingURL=hm.d.ts.map