Crates.io | temply-derive |
lib.rs | temply-derive |
version | 0.3.0 |
source | src |
created_at | 2022-02-17 18:45:31.430261 |
updated_at | 2022-03-24 22:18:20.03731 |
description | Procedural macro for temply |
homepage | |
repository | https://github.com/jannik4/temply |
max_upload_size | |
id | 534286 |
size | 62,642 |
temply is a simple, opinionated template engine. The syntax is derived from Jinja. Templates can be defined inline or in an external file and are validated at compile time.
Warning: temply currently does not handle html-escaping and is therefore not suitable for html templates. You may be looking for askama or ructe.
use temply::Template;
#[derive(Debug, Template)]
#[template_inline = "Hello {{ name }}!"]
struct MyTemplate<'a> {
name: &'a str
}
fn main() {
// Init template
let template = MyTemplate { name: "World" };
// Render
let mut buffer = String::new();
template.render(&mut buffer).unwrap();
assert_eq!(buffer, "Hello World!");
}