upon

A simple, powerful template engine.

Features

Still to come...

Getting started

Your entry point is the compilation and rendering Engine, this stores the delimiter settings and filter functions. Generally, you only need to construct one engine.

rust let engine = upon::Engine::new();

Compiling a template returns a reference to it bound to the lifetime of the engine and the template source.

rust let template = engine.compile("Hello {{ user.name }}!")?;

The template can then be rendered by calling .render().

rust let result = template.render(upon::value!{ user: { name: "John Smith" }})?; assert_eq!(result, "Hello John Smith!");

You can also use add_template(name, ...) and get_template(name).render(...) to store a template by name in the engine.

```rust let mut engine = upon::Engine::new(); engine.add_template("hello", "Hello {{ user.name }}!")?;

// later...

let template = engine.gettemplate("hello").unwrap(); let result = template.render(upon::value!{ user: { name: "John Smith" }})?; asserteq!(result, "Hello John Smith!"); ```

Examples

See more in the docs.

Benchmarks

The following shows a violin plot of the benchmark results for upon compared to the following template rendering engines. - handlebars - minijinja - tera - tinytemplate

Obviously, each of these engines has a completely different feature set so this just compares the performance for some of the features that upon supports.

Violin plot of benchmark results

Host - MacBook Pro (14-inch, 2021) - Chipset: Apple M1 Pro - Memory: 16 GB

License

Licensed under either of

at your option.