8 releases

0.3.4 Dec 1, 2023
0.3.3 Oct 27, 2023
0.2.1 Oct 25, 2023
0.1.0 Oct 24, 2023

#334 in Template engine

Apache-2.0

38KB
849 lines

russx

Documentation Latest version

Russx implements a template rendering engine based on rstml. It generates Rust code from your templates at compile time using a macro. This crate is inpired by both Askama and Leptos.

Features

  • Template instantiation
  • For loops, if-else statements, if-let statements, match statements
  • Full rust variables
  • Opt-out HTML escaping
  • Optional built-in support for Actix-Web, Axum, Gotham, Rocket, Tide, and warp web frameworks.

How to get started

First, add the russx dependancy to your crate's Cargo.toml:

cargo add russx

In any Rust file inside your crate, add the following:

use russx::Template;

russx::templates! {
    pub fn hello<'a>(name: &'a str) {
        <p>Hello, {name}!</p>
    }
}

fn main() {
    let html = hello("world").render().unwrap();
    println!("{html}");
}

You should be able to compile and run this code.

Dependencies

~0.5–39MB
~565K SLoC