But as someone who works on a sprawling set of template files with loads of sprinkled conditionals in a template language... the idea of using a "real language" for the templating, and in particular having type checking and proper abstraction tools (you can just write functions! No weird template tag tricks) is so much nicer to me.
HTML templates have always felt super brittle to me, basically at the level of C preprocessor programming. Even just with React/TS you can get away with so much with way more confidence given the typed backing.
Though I think that you _could_ get away with some nice tricks in Rust thanks to macros, where you ingest the template files and generate render functions with all the properties... or something like that.
Plus, Maud has a definitive speed advantage from what I've noticed.
Sadly, there isn't any great alternative for making performant HTML templates in Rust from what I've seen, a lot of the other HTML templating libs aren't that great comparatively.
I'd say it's actually a disadvantage. Front end engineers will work with HTML with embedded logic (as little as possible - values, iterators, conditionals). Generating HTML from Rust code is nice for simple things, but won't work with complicated HTML templates when those are required and will be harder to integrate with front-end applications. It's possible to compile a template with embedded logic (Java Server Pages did that in the late 1990's) to performant and type safe code. An approach like that would be great for Rust (someone must have done it by now)
And I dispute it not working with complicated HTML templates, that's handling it fine and integrates very well since I share code between frontend and backend anyway.
So even if it's not the "optimal approach" as you title it, it's the ergonomic approach for me because it doesn't get in my way.
https://djc.github.io/askama/creating_templates.html#the-tem...
Regardless, it's good to see some variety and experimentation like Maud in software design
Ideally, I'd imagine just making a "Global<T>" struct, where I insert the current page context like so "Global<LoginPage>" to get the final template. Though by the looks, it sounds more like LoginPage will simply have to have all the global context available via some attribute like "LoginPage.global".
Which others have you tried, and why do you think they're not great?
Horroshow, ructe, typed-html and yarte were okay but inheritance was underdocumented (or generally not as well documented), which is a big no for me. And a few only give minor-quality help at compile time.
Maud on the other hand has decent compiletime help and doesn't require a lot of documentation as normal rust code is doing the heavy lifting.
My main worry on things is that I'd rather like being able to express the inheritance in the type system through generics. Ie, having a top level "Page<T>" struct in which I can start putting the various subparts needed to render a page. It seems askama is doing it the other way round with a "parent" member needed in the child page.
But once you start getting to a few pages it's so much less cognitive overhead to separate concerns out into proper html files/templating.
It seems quite daunting to have a large project where all your html is inside rust files and a lot harder to find people who can work on it proficiently.