Skip to content

Instantly share code, notes, and snippets.

@cidrblock
Created August 17, 2022 13:11
Show Gist options
  • Save cidrblock/6768a4c998eab025e3357ff8181b3d67 to your computer and use it in GitHub Desktop.
Save cidrblock/6768a4c998eab025e3357ff8181b3d67 to your computer and use it in GitHub Desktop.
import jinja2
def to_template(string):
return f"{{{{ {string} }}}}"
env = jinja2.Environment()
string = "{# a comment #}{{ 'bar' | foo }}"
parsed_a = env.parse(string)
string = "{{ 'bar'|foo }}"
parsed_b = env.parse(string)
assert parsed_a == parsed_b
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment