Is there something like "a-h/templ" for Rust?

Is there something like GitHub - a-h/templ: A language for writing HTML user interfaces in Go. for Rust?

It's unclear to me what it is you are looking for exactly. Are you just looking for a templating engine or is your focus on having a templating engine that enables you to write inline html, i.e. with a macro? In case you just want the former, there a quite a few. In case the latter, I'm currently not aware of any.

1 Like

Rust has very strong support for embedding DSLs directly in Rust code. There are several options which take advantage. E g. Leptos uses a jsx-like syntax.

1 Like

The simplest one to use for server-side rendering is likely maud.

It looks like this:

use maud::html;

fn main() {
    let name = "Title";
    let markup = html! {
        h1 { "Poem: " (name) }
        p {
             strong { "Rock," }
            " you are a rock."
        }
    };
    println!("{}", markup.into_string());
}
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.