Crates.io | templr_macros |
lib.rs | templr_macros |
version | 0.2.2 |
source | src |
created_at | 2024-01-09 21:52:08.456752 |
updated_at | 2024-04-14 12:19:35.92611 |
description | Procedural macros for templr |
homepage | https://github.com/PizzasBear/templr |
repository | https://github.com/PizzasBear/templr |
max_upload_size | |
id | 1094663 |
size | 51,786 |
A templ inspired rust template engine. templr generates Rust code from your templates at compile time using a macro.
for
, if-else
, if-let
, match
, and let
statements (allowed in start tags!)First, add the templr dependancy to your crate's Cargo.toml
:
cargo add templr
In any Rust file inside your crate, add the following:
use templr::{Template, templ, templ_ret};
pub fn hello(name: &str) -> templ_ret!['_] {
templ! {
<p>Hello, {name}!</p>
}
}
fn main() {
let html = hello("world").render(&()).unwrap();
println!("{html}");
}
You should be able to compile and run this code.