jinja
jinja copied to clipboard
fix f-string syntax error in code generation
I've fixed a bug that caused an f-string syntax error in the template compilation when a template, that imports a macro, contains curly braces in its name. The bug was caused by the code-generation of an f-string in which the template name is inserted, and when the template name contains curly braces and the generated code gets executed, Python treats the curly braces as f-string braces. I've changed the code-generation to construct the string differently, such that the affected substring is not an f-string. Instead, the different substrings are concatenated using the +
operator.
- fixes #1792
Checklist:
- [x] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
- [ ] Add or update relevant docs, in the docs folder and in code.
- [x] Add an entry in
CHANGES.rst
summarizing the change and linking to the issue. - [ ] Add
.. versionchanged::
entries in any relevant code docs. - [x] Run
pre-commit
hooks and fix any issues. - [x] Run
pytest
andtox
, no tests failed.
I don't think any of the errors were introduced by this PR.
I've rebased this PR onto the latest state of the 3.1.x
branch. All tests are passing except pre-commit.ci - pr
, but the reported errors originate from 3.1.x
and weren't introduced by this PR.
@davidism (or any other maintainer) – may I ask you for a review? :pray: