home ~ socials ~ projects ~ rss

Use Jinja For Template Output In Python

January 2025
from jinja2 import Environment, select_autoescape

env = Environment(
    autoescape=select_autoescape()
)

template = env.from_string("""
Hello, {{ name }}!
""")

output = template.render(name="World")

print(output)
Output:
Hello, World!
end of line
Share link:
https://www.alanwsmith.com/en/2s/55/uw/xq/?use-jinja-for-template-output-in-python