( tagName: string, attrs?: Record<string, string | boolean>, )
| 15 | } |
| 16 | |
| 17 | export function htmlOpen( |
| 18 | tagName: string, |
| 19 | attrs?: Record<string, string | boolean>, |
| 20 | ): string { |
| 21 | const attrStr = attrs |
| 22 | ? Object.entries(attrs) |
| 23 | .map(([key, value]) => { |
| 24 | if (value == null || value === false) return; |
| 25 | key = ` ${escapeHtml(key)}`; |
| 26 | if (value === true) return key; |
| 27 | return `${key}="${escapeHtml(value)}"`; |
| 28 | }) |
| 29 | .filter(Boolean) |
| 30 | .join('') |
| 31 | : ''; |
| 32 | return `<${tagName}${attrStr}>`; |
| 33 | } |
| 34 | |
| 35 | export function htmlClose(tagName: string): string { |
| 36 | return `</${tagName}>`; |
no test coverage detected