The Jinja templating engine works well to create LaTeX templates for generating PDF files. The only issue is the default Jinja block, variable, and comment identification strings can conflict with the LaTeX commands. A solution is to change the Jinja environment to mimic the LaTeX environment.
Here is an example. This is the python file test.py: