Skip to content

Commit

Permalink
[New] htmpl: added raw
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien committed Sep 12, 2024
1 parent b710e0b commit c3d729d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/py/extra/utils/htmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def iterHTML(self) -> Iterator[str]:
yield from self.iterXML(html=True)

def iterXML(self, html=False) -> Iterator[str]:
if self.name == "#text":
if self.name == "#raw":
yield str(self.attributes.get("#value") or "")
elif self.name == "#text":
yield escape(str(self.attributes.get("#value") or ""))
elif self.name == "--":
yield "<!--"
Expand Down Expand Up @@ -225,6 +227,10 @@ def markup(name: str, tags: list[str | LiteralString]) -> Markup:
H: Markup = markup("html", HTML_TAGS)


def raw(html: str) -> Node:
return Node("#raw", attributes={"#value": html})


def html(
*nodes: Node, doctype: str | None = None, children: Node | list[Node] | None = None
) -> Iterator[str]:
Expand Down

0 comments on commit c3d729d

Please sign in to comment.