You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frompathlibimportPathfromyasha.cliimportcliPath('template.j2').write_text("{{ var is string }}, {{ var }}")
cli(['--var=foo', 'template.j2'], standalone_mode=False)
assertPath('template').read_text() =='True, foo'cli(['--var=foo', 'template.j2'], standalone_mode=False)
assertPath('template').read_text() =='True, foo'
everything works fine.
If, instead, i run this code:
frompathlibimportPathfromyasha.cliimportcliPath('template.j2').write_text("<< var is string >>, << var >>")
Path('extensions.py').write_text("""BLOCK_START_STRING = '<%'BLOCK_END_STRING = '%>'VARIABLE_START_STRING = '<<'VARIABLE_END_STRING = '>>'COMMENT_START_STRING = '<#'COMMENT_END_STRING = '#>'""")
cli(['--var=foo', '-e', 'extensions.py', 'template.j2'], standalone_mode=False)
assertPath('template').read_text() =='True, foo'Path('template.j2').write_text("{{ var is string }}, {{ var }}")
cli(['--var=foo', 'template.j2'], standalone_mode=False)
assertPath('template').read_text() =='True, foo'# -> AssertionErrorPath('template').read_text() # -> '{{ var is string }}, {{ var }}'
The second call to cli fails, it prints the entire template, unrendered, to the output file. It appears jinja no longer recognizes that second template as a template, and just treats it as text. I suspect that although the second cli call doesn't use the extensions file, the jinja configuration overrides in that file are persisting somewhere in the python interpreter's global state
The text was updated successfully, but these errors were encountered:
If i run the following code:
everything works fine.
If, instead, i run this code:
The second call to
cli
fails, it prints the entire template, unrendered, to the output file. It appears jinja no longer recognizes that second template as a template, and just treats it as text. I suspect that although the secondcli
call doesn't use the extensions file, the jinja configuration overrides in that file are persisting somewhere in the python interpreter's global stateThe text was updated successfully, but these errors were encountered: