from jinja2 import Template
t = '{% set name=name or "John Doe" %}Hello {{ name }}'
template = Template(t)
print(template.render(name='Jonnie Doe'))
print(template.render())
Sane way to define default variable values from within a jinja template?