Thanks to visit codestin.com
Credit goes to lib.rs

5 releases

Uses new Rust 2024

0.1.4 Aug 25, 2025
0.1.3 May 31, 2025
0.1.2 May 31, 2025
0.1.1 May 31, 2025
0.1.0 May 31, 2025

#350 in Template engine

Codestin Search App

497 downloads per month

MIT license

22KB
327 lines

avosetta

A fast, minimal html templating language for Rust.

GitHub Actions Workflow Status Crates.io Version docs.rs Crates.io Total Downloads GitHub License

about

avosetta is a minimal templating library for that utilises procedural macros to generate as close to optimal code as possible for rendering html content at runtime. It has no unsafe code, only a handful of dependencies, and does not allocate any values on the heap.

We implement a terse, simple syntax for specifying templates that is straightforward to parse, has little ambiguity and integrates into Rust code better. And unlike other templating libraries such as maud, our syntax typically only has a single way of writing various constructs, reducing code-style clashing. For more information, read the full syntax reference here.

Optimisations include automatically escaping static string literals at compile-time and collapsing contiguous String::push_str calls into a single one. Therefore, if your html fragment is entirely static, the generated code will just be a single String::push_str with a &str.

getting started

To start using avosetta, you'll first need to add our package to your Cargo.toml manifest:

cargo add avosetta

Then you can start writing html templates directly in your Rust source code.

use avosetta::prelude::*;

fn main() {
  let mut s = String::new();
  index().write(&mut s);

  println!("{s}");
}

fn index() -> impl Html {
  html! {
    @layout(
      html! {
        title { "avosetta" }
      },

      html! {
        h1 { "Hello, World!" }
      },
    )
  }
}

fn layout(
  head: impl Html,
  body: impl Html,
) -> impl Html {
  html! {
    "!DOCTYPE"[html];
    html[lang="en"] {
      head {
        meta[charset="UTF-8"];
        meta[name="viewport", content="width=device-width,initial-scale=1"];

        @head
      }

      body {
        main {
          @body
        }
      }
    }
  }
}

Dependencies

~74–540KB
~12K SLoC