You can use a similar process to what you already have with jinja templating. In fact, you could even use jinja to create a typst document rather than whatever document format you are using right now (I assume you’re doing HTML then converting to PDF).
So, if for example:
<h1>{{ some_heading }}</h1>
<p> Some {{ some_value }} </p>
You’d convert that to
= {{ some_heading }}
Some {{ some_value }}
and so on.
You would then
- populate the template with values,
- output a temporary typst file
- use subprocess and convert it to PDF using typst compile.
- delete the temporary file (if need be)
- serve the PDF
The bottom line is that you are producing a string, writing it to file, and using typst to convert it. There are multiple ways to produce that string, jinja being one of them (and not a bad option imo).