This repository has been archived on 2026-10-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

23 lines
456 B
Python
Raw Permalink Normal View History

2026-05-20 23:55:27 +02:00
from __future__ import annotations
import html
class SafeHtml(str):
"""HTML fragment that was built by trusted server-side template helpers."""
def escape(value: object) -> str:
return html.escape(str(value), quote=True)
def attr(value: object) -> str:
return escape(value)
def trusted(fragment: str) -> SafeHtml:
return SafeHtml(fragment)
def join_html(fragments: list[str]) -> SafeHtml:
return SafeHtml("".join(fragments))