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.
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.