6 ms·
Maud is wonderful for small things like a stats page or dashboard. But once you start getting to a few pages it's so much less cognitive overhead to separate c
by Grimburger 4y ago
Maud is wonderful for small things like a stats page or dashboard.
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.
- Inviz 4y agoI wish it was still the consensus among JS devs. People are putting css into JS files, on top of html
- vonadz 4y agoI think it isn't the consensus anymore because there isn't actually a "correct" solution. It's too subject to personal preference. For example, I prefer having HTML + CSS + JS all in the same file because then I know everything relevant to the component or page I'm working on is right there. I do concede that it can get extremely unwieldy if you don't separate out components though.
- My71staccount 4y agoThere is a correct solution (the one you're not doing)
- vonadz 4y agoSure, just like there's a correct IDE.
- zaarn 4y agoOne of the huge advantages of Maud is that it keeps code and markup close together, so you can do things like having rust control structures determine what markup is used later on (for snippets or widgets, for example). 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.
- dochtman 4y ago> 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. Which others have you tried, and why do you think they're not great?
- zaarn 4y agoI've tried handlebars and liquid. They're okayish, but both slow and don't have any compiletime help or typing when I tried them. 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.
- dochtman 4y agoI created Askama (which yarte forked), the inheritance docs aren't great but also not too bad. Curious why you didn't try it?
- zaarn 4y agoI haven't found askama yet, or rather, discovered it through HN here, I don't check the arewewebyet.org site too often and it's my main source of frameworks to find. 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.
- rbanffy 4y ago> One of the huge advantages of Maud is that it keeps code and markup close together 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)
- rtpg 4y agoI do, in theory, understand separation of concerns. 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.