sanic-org / html5tagger

Create HTML documents from Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add real world examples

legout opened this issue · comments

Hi,

Adding some more advanced examples would be nice.

  • How does it play together with web frameworks like sanic, flask or fastapi?
  • How can I replace jinja2 with html5tagger
  • Does it work with htmx?

Thanks :-)

Sanic documentation for this is pending. But in short, you just return sanic.response.html(doc) and other frameworks probably work similarly (convert to string first if it doesn't).

Jinja2 is a more complicated matter. Rewrite all your HTML and Jinja2 loops in html5tagger and Python, remove all your escaping (as this is done automatically by html5tagger).

HTMX attributes work as usual, just use underscores instead of hyphens.

Great. I’ll give it a try. Thanks.