-
-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent template path behavior across platforms #383
Comments
I'm honestly not sure whether I want to support templates in directories outside of those directly configured. I am confused that there's an OS difference here, though. |
That's understandable, considering |
So, I've been digging, and the short version is that this is a Rust standard library issue and not an askama issue. The longer version is, I tracked down where the differing behavior happened, and it was in askama/askama_shared/src/lib.rs Lines 103 to 127 in 403a0b0
On Unix it always returned In short. I had no directory called The Rust docs didn't really mention this inconsistency, so I'll forward this issue to Rust's issue tracker. |
I've encountered a bug with template paths. Which is triggered if
templates/
is missing and another directory is used instead. I was quite confused, as the code worked perfectly fine on my Windows machine. However, my CI running Ubuntu failed. I then had the CI also build on Windows and MacOS as well, and apparently it fails on both Ubuntu and MacOS, but not Windows.I spent some time and figured out what triggers it.
I don't have my templates inside
templates/
I have them insideclient/templates/
. If I interpret the docs correctly, I'm assuming thattemplates
is simply joined withpath
. So naturally, myindex.html
, I'd write it as../client/templates/index.html
.However, doing so fails in the same way on both Ubuntu and MacOS with the following error, that the template is not found:
Workaround 1
If I simply create the
templates/
directory, and leave it empty. Then the code successfully builds on all 3 platforms.Workaround 2
Alternatively, having an
askama.toml
withclient/templates
indirs
works as well:However, I only first discovered
askama.toml
while trying to find out what caused the issue in the first place.Minimal, Reproducible Example
client/templates/index.html
.templates/
directory does not existaskama = "0.10"
main.rs
cargo build
and the previous error appears on Ubuntu and MacOSThe text was updated successfully, but these errors were encountered: