1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use srtemplate::SrTemplate;

#[derive(Clone)]
struct Point {
    x: f32,
    y: f32,
}

impl ToString for Point {
    fn to_string(&self) -> String {
        format!("(x: {}, y: {})", self.x, self.y)
    }
}

fn main() {
    let ctx = SrTemplate::default();

    let p = Point { x: 0.0, y: 5.025 };

    ctx.add_variable("point", &p);

    let template = "Point {{ point }}";
    println!("Rendered: {}", ctx.render(template).unwrap());
}