INNER CODE UNIT · Python
format
volfpeter/htmy · htmy/core.py:207
def format(self) -> str:
"""
Raises `SkipProperty` for `XBool.false`, returns empty string for `XBool.true`.
"""
if self is XBool.true:
return ""
raise SkipProperty()
def xml_format_string(value: str) -> str:
"""Escapes `<`, `>`, and `&` characters in the given string, unless it's a `SafeStr`."""
return value if isinstance(value, SafeStr) else xml_escape(value)
class Formatter(ContextAware):
"""
The default, context-aware property name and value formatter.