mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-27 13:00:57 +00:00
17 lines
587 B
Rust
17 lines
587 B
Rust
use rinja::Template;
|
|
|
|
#[derive(Template)] // this will generate the code...
|
|
#[template(path = "hello.html")] // using the template in this path, relative
|
|
// to the templates dir in the crate root
|
|
struct HelloTemplate<'a> {
|
|
// the name of the struct can be anything
|
|
name: &'a str, // the field name should match the variable name
|
|
// in your template
|
|
}
|
|
|
|
#[test]
|
|
fn main() {
|
|
let hello = HelloTemplate { name: "world" }; // instantiate your struct
|
|
assert_eq!("Hello, world!", hello.render().unwrap()); // then render it.
|
|
}
|