Crates.io | bempline |
lib.rs | bempline |
version | 0.8.1 |
source | src |
created_at | 2020-02-11 21:45:59.129767 |
updated_at | 2022-10-15 01:56:01.19615 |
description | Simple template library |
homepage | |
repository | https://github.com/gennyble/bempline |
max_upload_size | |
id | 207468 |
size | 27,299 |
A simple template engine for simple things.
Variables are alphanumeric strings (underscores, too) surrounded by braces. Here's an {example}
.
You can prevent {word}
from being seen as a variable by escaping the opening brace. Like \{this}
.
If you have this document in something like template.bpl
Dear {name},
Some generic email text here!
Sincerely,
Some Company
You can fill it out for the names Ferris
and Rusty
like so
use bempline::Document;
fn main() {
let doc = Document::from_file("test/template.bpl").unwrap();
let names = vec!["Ferris", "Rusty"];
for name in names {
let mut cloned = doc.clone();
cloned.set("name", name);
println!("{}", cloned.compile());
}
}