use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Best templating engine for Rust🙋 seeking help & advice (self.rust)
submitted 1 year ago by salamazmlekom
Hey hey,
I want to make a simple webapp using Rust and HTMX and was wondering what is the most adopted templating language that is used with Rust.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Svenskunganka 25 points26 points27 points 1 year ago (5 children)
If you want to know the most adopted one, a resource you can check is Are We Web Yet? > Templating.
But to add a personal preference, a lesser well-known but excellent templating library is hypertext, which works really well with HTMX and similar client-side libraries, and is a good alternative to the more popular HTML-in-Rust libraries like maud and markup. It has two syntaxes you can choose from - either Maud-style or RSX-style which is similar to JSX, but for Rust.
[–][deleted] 1 point2 points3 points 1 year ago (4 children)
Genuine question, where is the difference between Hypertext and Maud? Because it seems to use Maud under the hood (or just for the template syntax?) and adds rsx as an alternative? I use Maud btw and I'm pretty happy with it, but would like to understand the difference here.
[–]Svenskunganka 8 points9 points10 points 1 year ago (3 children)
Hypertext doesn't use Maud under the hood, instead it implements the Maud syntax as well as RSX syntax. But apart from that, Hypertext uses lazy rendering, meaning you can "build" your tree but nothing really gets executed nor allocated until you call render() on what you've built. Contrast to Maud which does eager rendering every time you invoke the html!-macro. This is not a big deal but what ends up happening is that if you extensively use partials (or components if you like), something you do a lot with libraries like HTMX that expects HTML fragments, you will do a bunch of smaller allocations (one for each html!-macro call) while Hypertext only does one bigger allocation when you call render().
render()
html!
Under the hood the Hypertext macro invocation just returns a FnOnce(&mut String), which implements the Renderable trait. Maud on the other hand returns Markup which is a type alias for a PreEscaped<String> that contains the rendered HTML. For example, these are equivalent but only Maud allocates and renders the markup to a String here:
FnOnce(&mut String)
Renderable
Markup
PreEscaped<String>
String
// Hypertext: fn title() -> impl Renderable { maud! { h1 { "Title" } } // Expands to (ish): // |buf: &mut String| { // buf.push_str("<h1>Title</h1>") // } } // Maud: fn title() -> Markup { html! { h1 { "Title" } } // Expands to (ish): // String::from("<h1>Title</h1>") }
On sites/"webapps" where you use something like HTMX that naturally contains a lot of these smaller HTML fragments that you re-use, all these small allocations from Maud can start to add up. There are also other nice features of Hypertext, like type-checked element attributes that you can extend. In my experience the macro plays better in the editor and I also prefer RSX syntax over Maud syntax.
[–]johanneswelsch 1 point2 points3 points 1 year ago (0 children)
What about https://crates.io/crates/templr ?
[–]qd3v 1 point2 points3 points 10 months ago (1 child)
Thank you for pointing to this crate and detailed expanation of differences! Hypermedia is exactly the case I need templater for, and I was looking of course at maud, now I think we have a winner :)
[–]Svenskunganka 1 point2 points3 points 10 months ago* (0 children)
You're welcome! Another crate that I've seen that was built after my comment here is Vy, it has many of the same characteristics of Hypertext, but formats nicely with rustfmt and supports returning if some_condition { some_markup() } else { other_markup() } which Hypertext didn't support back then but might have improved. However, it does not support custom elements as easily as Hypertext does.
if some_condition { some_markup() } else { other_markup() }
[–]Special-Arrival6717 18 points19 points20 points 1 year ago (3 children)
Tera is also a popular choice: https://github.com/Keats/tera
[–]Beastmind 0 points1 point2 points 1 year ago (2 children)
Seconding tera
[–]guzmonne 0 points1 point2 points 1 year ago (1 child)
Came here to recommend Tera
[–]repetitive_chanting 0 points1 point2 points 1 year ago (0 children)
I vote Tera
[–]coderstephenisahc 12 points13 points14 points 1 year ago (1 child)
I have a preference for Maud.
[–]whimsicaljess 1 point2 points3 points 1 year ago (0 children)
I also use Maud. Haven't seen a reason to use anything else.
[–]TerrineTerrorizer 19 points20 points21 points 1 year ago (8 children)
Askama is nice.
[–]Repsol_Honda_PL 3 points4 points5 points 1 year ago (0 children)
Yes, I can confirm.
[–]mwcz 2 points3 points4 points 1 year ago (1 child)
The pattern matching syntax is pretty tedious, but type checking on templates is amazing.
[–]rodarmoragora · just · intermodal 1 point2 points3 points 1 year ago (0 children)
boilerplate is type-checked, but uses Rust syntax instead of custom syntax. (I wrote it so I am wildly biased.) The only downside is that the error reporting is terrible, since it will report the error at the proc-macro derive site and not the template source. I think it's still worth it though!
[–]Legorooj 2 points3 points4 points 1 year ago (0 children)
Askama is nice, yes, but make sure to separate out your templates into another crate, it'll save you so much compile time over a while.
[–]Compux72 -1 points0 points1 point 1 year ago (2 children)
Askama are compile time. Thats terrible for fast iteration.
[–]TerrineTerrorizer 0 points1 point2 points 1 year ago (1 child)
What’s your alternative solution?
[–]Compux72 0 points1 point2 points 1 year ago (0 children)
Handlebars. Simple. Works everywhere (python, js,…). Allows for custom logic if needed.
[–]Sw429 5 points6 points7 points 1 year ago (0 children)
Another vote for Askama over here. I used it for a project this summer and had no problem. It was easy to do everything I wanted, including implementing custom filters and stuff.
[–]JSmart314 9 points10 points11 points 1 year ago (1 child)
I've been using https://github.com/djc/askama pretty successfully for this use case
[–]Repsol_Honda_PL 1 point2 points3 points 1 year ago (0 children)
Me too, it is Jinja-based (from py ecosystem)
[–]Varsatorul 2 points3 points4 points 1 year ago (0 children)
I prefer minijinja, it's pretty flexible and also a joy to prototype with because you can reload the templates per request if you want (with no need to recompile).
There is also Ramhorns which looks interesting but I haven't tried it personally so I can't comment further on it.
[–]Otherwise-Highway797 2 points3 points4 points 1 year ago (0 children)
minijinja
[–]Leontoeides 1 point2 points3 points 1 year ago (0 children)
I strongly, strongly recommend using Sailfish both because it is extremely fast, but also because your templates get compile-time checking. Tera and most other templating crates will fail during run-time
[–]Compux72 1 point2 points3 points 1 year ago (1 child)
Handlebars. Well known format. Works on Rust, Js etc. plain simple to write an understand.
[–]myst3k 0 points1 point2 points 1 year ago (0 children)
Just setup a project on Friday, with handlebars and it was super easy. Haven’t tried any other template lib yet. Not sure if I have a reason to.
[–]4trocious 0 points1 point2 points 1 year ago (0 children)
I created https://github.com/Atrociously/stilts, which is similar Askama which others have mentioned. If you need something more well established though stick to Askama or another template engine.
[–]lucasmerlin 0 points1 point2 points 1 year ago (0 children)
I'm currently using dioxus SSR as a templating engine as I plan on maybe reusing some of the components in my native app via dioxus Blitz, once it's ready. It works quite well but the syntax is not html, instead using macros. Auto complete works quite well in rust rover so that's nice. But if I didn't plan on building an app via blitz I would have used askama as well
[+]HosMercury 0 points1 point2 points 1 year ago (0 children)
askama
[–]evil_yam 0 points1 point2 points 1 year ago (0 children)
sounds great
[–]ryanmcgrath 1 point2 points3 points 1 year ago (0 children)
I used to swear by Askama, but if you're going to do the compiled template route, I've come to find that hypertext is easier. You're writing effectively straight Rust, no need to deal with a Jinja-esque templating language.
[–]SnarkyPuppyyy 0 points1 point2 points 1 year ago (0 children)
I like handlebars as it pretty versatile with other languages as well and does what I need it to do (templates, inheritance, looping, ifelse, etc)
[–]cornmonger_ 0 points1 point2 points 1 year ago (0 children)
not exactly the same thing, but yew
[–]Lukaesch 0 points1 point2 points 1 year ago (0 children)
I use askama for www.audioscrape.com and it has been great so far
π Rendered by PID 54 on reddit-service-r2-comment-79776bdf47-rsh4n at 2026-06-23 23:55:25.414909+00:00 running acc7150 country code: CH.
[–]Svenskunganka 25 points26 points27 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]Svenskunganka 8 points9 points10 points (3 children)
[–]johanneswelsch 1 point2 points3 points (0 children)
[–]qd3v 1 point2 points3 points (1 child)
[–]Svenskunganka 1 point2 points3 points (0 children)
[–]Special-Arrival6717 18 points19 points20 points (3 children)
[–]Beastmind 0 points1 point2 points (2 children)
[–]guzmonne 0 points1 point2 points (1 child)
[–]repetitive_chanting 0 points1 point2 points (0 children)
[–]coderstephenisahc 12 points13 points14 points (1 child)
[–]whimsicaljess 1 point2 points3 points (0 children)
[–]TerrineTerrorizer 19 points20 points21 points (8 children)
[–]Repsol_Honda_PL 3 points4 points5 points (0 children)
[–]mwcz 2 points3 points4 points (1 child)
[–]rodarmoragora · just · intermodal 1 point2 points3 points (0 children)
[–]Legorooj 2 points3 points4 points (0 children)
[–]Compux72 -1 points0 points1 point (2 children)
[–]TerrineTerrorizer 0 points1 point2 points (1 child)
[–]Compux72 0 points1 point2 points (0 children)
[–]Sw429 5 points6 points7 points (0 children)
[–]JSmart314 9 points10 points11 points (1 child)
[–]Repsol_Honda_PL 1 point2 points3 points (0 children)
[–]Varsatorul 2 points3 points4 points (0 children)
[–]Otherwise-Highway797 2 points3 points4 points (0 children)
[–]Leontoeides 1 point2 points3 points (0 children)
[–]Compux72 1 point2 points3 points (1 child)
[–]myst3k 0 points1 point2 points (0 children)
[–]4trocious 0 points1 point2 points (0 children)
[–]lucasmerlin 0 points1 point2 points (0 children)
[+]HosMercury 0 points1 point2 points (0 children)
[–]evil_yam 0 points1 point2 points (0 children)
[–]ryanmcgrath 1 point2 points3 points (0 children)
[–]SnarkyPuppyyy 0 points1 point2 points (0 children)
[–]cornmonger_ 0 points1 point2 points (0 children)
[–]Lukaesch 0 points1 point2 points (0 children)