Skip to content
Myr

html.ts

This file

Path

src/utils/html.ts

13 lines · 383 bytes · TypeScript

Last changed by

refactor(html): make `html` as middleware (#319)Yusuke Wadabefore adoption5976a60

History of this file

Take it

feat: Introduce html template literals tag. (#312)Taku Amanobefore adoption9488e33

lines 1–2why, one step back
1export type HtmlEscapedString = string & { isEscaped: true }
2

Merge pull request #306 from honojs/feat/jsxYusuke Wadabefore adoption583d3d4

lines 3–12why, one step back
3const entityMap: Record<string, string> = {
4 '&': '&amp;',5 '<': '&lt;',6 '>': '&gt;',7 '"': '&quot;',8}9const escapeRe = new RegExp(`[${Object.keys(entityMap).join('')}]`, 'g')10const replaceFn = (m: string) => entityMap[m]11export const escape = (str: string): string => {12 return str.replace(escapeRe, replaceFn)

feat: Introduce html template literals tag. (#312)Taku Amanobefore adoption9488e33

line 13why, one step back
13}