Skip to content

Instantly share code, notes, and snippets.

@jamescarr
Last active September 18, 2024 14:55
Show Gist options
  • Save jamescarr/0205f889e1a87157fb941a54beb257db to your computer and use it in GitHub Desktop.
Save jamescarr/0205f889e1a87157fb941a54beb257db to your computer and use it in GitHub Desktop.
Test jinja2 out in a console quickly. If you have jinja2 installed locally just open a python REPL and do this!
from jinja2 import Template
text = """
hi {{ name|default(other_name) }}
"""
template = Template(text)
template.render(name="foo") # passing variables here to the text template if needed
template.render(other_name="bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment