Something went wrong. Try again.
Paper Mario mod hosting site - AT Protocol appview starhaven.dev
appview
Something went wrong. Try again.
1.0 kB · 32 lines
JavaScript
at main
123456789101112131415161718192021222324252627282930313233const ESC = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
const SLOT_PREFIX = "\x00slot:";let slotId = 0;
export function html(strings, ...values) { const t = document.createElement("template"); const slots = new Map(); let markup = strings[0]; for (let i = 0; i < values.length; i++) { const v = values[i]; if (v instanceof DocumentFragment || v instanceof Node) { const id = SLOT_PREFIX + slotId++; slots.set(id, v); markup += `<template data-slot="${id}"></template>`; } else { markup += String(v).replace(/[&<>"']/g, (c) => ESC[c]); } markup += strings[i + 1]; } t.innerHTML = markup; for (const [id, node] of slots) { t.content.querySelector(`[data-slot="${id}"]`).replaceWith(node.cloneNode(true)); } return t.content;}
export function css(strings, ...values) { const sheet = new CSSStyleSheet(); sheet.replaceSync(String.raw(strings, ...values)); return sheet;}