31 ms·
I've been doing something very similar in Rust recently using Askama or Maud for templates (components), optionally with Axum to include a server in the binary.
by jackothy 2y ago
I've been doing something very similar in Rust recently using Askama or Maud for templates (components), optionally with Axum to include a server in the binary.
The author mentions wanting to colocate templates with logic, Maud allows much tighter/automatic integration in this regard.
This approach also synergizes almost perfectly with HTMX.
- rkwz 2y ago> Maud allows much tighter/automatic integration in this regard Interesting, can you share some examples?
- jackothy 2y agoIn the linked Go approach, and also with Askama, you have to define each template (component) twice. Once as a .html file, and then again as a struct inside a source file. With Maud, templates/components are only defined once, so you no longer have to worry about keeping the two in sync or colocating them. This is because Maud provides a macro for writing HTML with Rust-like syntax, so all your HTML (components) ends up inside regular Rust files, and you can refer to variables as usual. This really makes for almost seamless integration between Rust code and the HTML you serve.
- Klonoar 2y agoI do this but using hypertext, since the syntax is closer to JSX and less confusing for others to touch.
- jackothy 2y agoJust checked out hypertext! Have you noticed any other advantages over Maud, except for syntax?
- sgt 2y agoRecently rediscovered htmx and applied it to a Django project. It really does give that SPA feeling without much of a hassle, and it's also easier in a team setting where there's less stepping on other people's toes, which is often the case with a full blown Vue or React app.