Text Placeholder
A flexible text template engine that allows templates with named placeholders within it.
Placeholders are defined by default following the handlebars syntax, but can be overriden with specific boundaries.
In order to provide the context in which our placeholders will be replaced the following options are available:
- Provide a HashMap and use
fill_with_hashmap
orfill_with_hashmap_strict
- Provide a Struct and use
fill_with_struct
orfill_with_struct_strict
- :warning: This is an optional feature that depends on
serde
andserde_json
:warning:
- :warning: This is an optional feature that depends on
Example
use Template;
use HashMap;
let default_template = new;
let mut table = new;
table.insert;
table.insert;
assert_eq!;
// We can also specify our own boundaries:
let custom_template = new_with_placeholder;
assert_eq!;
Roadmap
- Allow objects that implement trait
std::ops::Index
instead of depending on a HashMap.
This project is inspired by the awesome text-template repository.