avosetta-macros

Crates.ioavosetta-macros
lib.rsavosetta-macros
version0.1.4
created_at2025-05-31 18:47:24.294422+00
updated_at2025-08-25 21:28:35.082191+00
descriptionA fast, minimal html templating language for Rust.
homepage
repositoryhttps://github.com/callum-hopkins-dev/avosetta
max_upload_size
id1696546
size28,496
Callum Hopkins (callum-hopkins-dev)

documentation

https://docs.rs/avosetta

README

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
        }
      }
    }
  }
}
Commit count: 39

cargo fmt