Development

This commit is contained in:
Matthew Grotke 2026-06-01 22:44:32 -04:00
parent 22b18897b6
commit 7da1630ab3
3 changed files with 24 additions and 6 deletions

View file

@ -1,4 +1,4 @@
# factory.py JSON content-type renderer
# factory.py: JSON content-type renderer
# Converts content.json item trees into HTML strings.
# Pure type processing: no data loading, no routing, no layout.
from flask import session
@ -46,7 +46,7 @@ def _prefix_to_dotted(n):
def apply_tokens(text, tokens):
"""Substitute %TOKEN% placeholders. Values are NOT auto-escaped — callers
"""Substitute %TOKEN% placeholders. Values are NOT auto-escaped. Callers
that use results in HTML attribute or text context must call e() themselves."""
return re.sub(r'%([A-Z_]+)%', lambda m: str(tokens.get(m.group(1), m.group(0))), text)