Struct edo::Edo [] [src]

pub struct Edo<'a> { /* fields omitted */ }

A single template. Allows registering of handlers and rendering

Methods

impl<'a> Edo<'a>
[src]

Creates a new template instance.

Examples

let template = Edo::new("Hello {name}");

Register a new function handler

Examples

let mut template = Edo::new("Hello {name}").unwrap();
template.register_handler("name", |_| String::from("World!"));

Register a static replacement

Examples

let mut template = Edo::new("Hello {name}").unwrap();
template.register_static("name", "World!");

Render template into a string

Examples

let mut template = Edo::new("Hello {name}").unwrap();
template.register_handler("name", |_| String::from("World!"));
let output = template.render();
assert_eq!(output, "Hello World!");