I'm working on my first toy web app with Rust, Actix-Web, and Askama. There are a few frontend assets that I build with Vite. Among other things, this bundles my JS-code into a single file with a version hash. Asset symbolic name's are mapped to their hashed names in a manifest.json file.
I can think of several ways to handle this, but the one I currently prefer goes like this:
I already have a cargo build script that handles building the assets through Vite. I would like to write Askama templates with two different syntaxes. The default syntax for rendering at runtime as usual. An alternative syntax for use in a preprocessing step in the build script where symbolic names are mapped to their hashed counterparts.
I barely understand the Askama sources and unfortunately what I'm trying to achieve seems to be at odds with how Askama does things. I may have to use another templating engine just for preprocessing; or just go for simple, textual search & replace.
I'm rather attached to handling this at build time. But if I were to switch to a runtime approach, I think my best bet would be a custom Askama filter for looking up hashed asset names.
I'm looking forward to your suggestions.