With this template structure:
/templates/
+- {% jinja expr %}.jinja
+- macro_file.jina
When {% jinja expr %}.jinja imports a macro using 'from "macro_file.jinja" import my_macro' syntax, Environment.render fails with SyntaxError: f-string: invalid syntax error message.
Internally jinja concatenates the importing template filename into an f-string, which results with invalid f-string:
if l_0_print_helo is missing:
l_0_print_helo = undefined(f"the template {included_template.__name__!r} (imported on line 1 in '{% if True %}a{%endif%}.txt.jinja') does not export the requested name 'print_helo'", name='print_helo')
Couldn't reproduce the error using import "macro_file.jinja" as m syntax.
Environment:
- Python 3.10.7
- Jinja 3.1.2
With this template structure:
When
{% jinja expr %}.jinjaimports a macro using 'from "macro_file.jinja" import my_macro' syntax, Environment.render fails withSyntaxError: f-string: invalid syntaxerror message.Internally jinja concatenates the importing template filename into an f-string, which results with invalid f-string:
Couldn't reproduce the error using
import "macro_file.jinja" as msyntax.Environment: