-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Configure template paths for debug and release. #1103
Comments
Hmm, I don't think there is a clean way to do this, but feel free to propose a design. |
Option 1: Set alternative debug path in the macro.#[derive(Template)]
#[template(
path = "./static/pages/settings.html",
debug = "./dist/pages/settings.html"
)]
pub struct SettingsPage {
pub profile: UserProfile,
} Askama would use the HTML file in Option 2: Add a 'debug-dirs' key to the config file[general]
dirs = ["./static/pages", "./static/templates"]
debug-dirs = ["./dist/pages", "./static/templates"] |
How would Askama detect whether the calling code is compiled in debug mode? As I understand it, each crate may be compiled with a separate profile, and as a procedural macro crate, the profile with which Askama is compiled doesn't necessarily match the profile the calling code is compiled with. |
I was under the impression that If that is not the case, perhaps this could work: Option 3: 'debug' feature in dev-dependencies[dependencies]
askama = { version = "0.12.1", features = ["with-axum"] }
[dev-dependencies]
askama = { version = "0.12.1", features = ["with-axum", "debug"] } Specifying the debug feature in the dev dependencies would cause Askama to use a [general]
dirs = ["./dist"]
[debug]
dirs = ["./static"] |
Yeah, I don't think any of this really makes sense. I suggest you write a custom procedural macro to abstract over the |
I'm using Vite for my application, which is used to build the app, but does not run during development. While in debug mode, I want askama to load templates from
/static
, but load from/dist
during dev. it would be nice if I could configure a debug mode in the Askama.toml without having to do a bunch of ugly #[cfg_attr on each of my templates.The text was updated successfully, but these errors were encountered: