Tera - list templates
I am not sure if this is ever needed in an application, but it helped me when first I could not figure out the expected directroy layout. It might be used for debugging to see if Tera can really find your templates.
$ tree
.
├── Cargo.lock
├── Cargo.toml
├── out.out
├── src
│ └── main.rs
└── templates
├── hello.html
└── incl
└── header.html
use tera::Tera; fn main() { let tera = Tera::new("templates/*.html").unwrap(); tera.get_template_names().for_each(|x| println!("{}", x)); }
incl/header.html
hello.html
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
[dependencies]
tera = "1.20.0"
Hello, {{name}}!
<html>
<head>
</head>