Skip to content

Add CARGO_MANIFEST_DIR as second templates default location#703

Open
useche wants to merge 1 commit intoaskama-rs:mainfrom
useche:main
Open

Add CARGO_MANIFEST_DIR as second templates default location#703
useche wants to merge 1 commit intoaskama-rs:mainfrom
useche:main

Conversation

@useche
Copy link

@useche useche commented Feb 26, 2026

In build environments where CARGO_MANIFEST_DIR is not set, the templates paths are prepended with a templates directory that doesn't exist in a random place. For instance, in Android's Soong, askama ends up looking for the templates directory in the root of the Android code. By adding the root directory as well, it gives us the chance to specify a relative path from wherever the compilation happens.

Note that this cannot be solved with askama.toml either because its location is tied to CARGO_MANIFEST_DIR too.

template.

In build environments where `CARGO_MANIFEST_DIR` is not set, the
templates paths are prepended with a `templates` directory that doesn't
exist in a random place. For instance, in Android's Soong, askama ends
up looking for the `templates` directory in the root of the Android
code. By adding the `root` directory as well, it gives us the chance to
specify a relative path from wherever the compilation happens.

Note that this cannot be solved with `askama.toml` either because its
location is tied to `CARGO_MANIFEST_DIR` too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant