Crates.io | templr_parser |
lib.rs | templr_parser |
version | 0.2.1 |
source | src |
created_at | 2024-01-09 21:50:12.760365 |
updated_at | 2024-03-01 11:33:58.197012 |
description | Parser for templr templates |
homepage | https://github.com/PizzasBear/templr |
repository | https://github.com/PizzasBear/templr |
max_upload_size | |
id | 1094653 |
size | 52,834 |
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.