Posted on :: Tags: ,

Tera

🍇 Slow and steady wins the race.

Usage

The primary method of using Tera is to load and parse all the templates in a given glob.

templates/
  hello.html
  index.html
  products/
    product.html
    price.html

Assuming the Rust file is at the same level as the templates folder, we can get a Tera instance that way:

use tera::Tera;

// use globbing
let tera = match Tera::new("templates/**/*.html") {
  Ok(t) => t,
  Err(e) => {
    println!("Parsing error(s): {}", e);
    std::process::exit(1);
  }
}