Skip to main content

Crate philiprehberger_template

Crate philiprehberger_template 

Source
Expand description

Lightweight string template engine with variables, conditionals, and loops.

Zero external dependencies. Uses a simple HashMap<String, Value> approach.

§Examples

use philiprehberger_template::{Template, Value};
use std::collections::HashMap;

let tpl = Template::parse("Hello, {name}!").unwrap();
let mut data = HashMap::new();
data.insert("name".into(), Value::from("world"));
assert_eq!(tpl.render(&data).unwrap(), "Hello, world!");

Structs§

Template
A parsed template that can be rendered with data.

Enums§

ParseError
An error that occurs during template parsing.
RenderError
An error that occurs during template rendering.
Value
A dynamic value that can be inserted into a template.