jinja2.exceptions.TemplateNotFound
niccokunzmann opened this issue · comments
The bug can be replicated under Windows.
The whole description is here: niccokunzmann/open-web-calendar#86 reported by @nhxyz.
Environment: Windows
- Python version: 3.??
- Jinja version: 3.1.1
Fix:
Found It ! I replaced on line 30 of lib\jinja\loaders.py by
for piece in template.split("\\"):
It all works now
Jinja exclusively uses forward slashes in template paths. Do not use os.path.join
for template paths; if you really want to use it, use posixpath.join()
which always uses forward slashes.
Jinja templates are referenced by names, not by paths. Names can have any characters in them. When using the filesystem loader, the names happen to look the same as the directory and file names, but normalized to the /
separator. It's not a value error for a name to have a \
in it, it's only an error to refer to a name that Jinja doesn't know how to load. The TemplateNotFoundError
already corresponds to that, there's no other error that should be raised.