String Template
String templates are strings with dynamic components that can be rendered for each node based on the node attributes.
A simple template can be like below:
Hi, my name is {name}, my address is {address?"N/A"}.
I wrote this document on {%A}, exact date: {%Y-%m-%d}.
Results (with: name=John; address=123 Road, USA):
Hi, my name is John, my address is 123 Road, USA.
I wrote this document on Monday, exact date: 2025-01-27.
With more complicated templates, we would be able to generate documents with text and images based on the node attributes as well.
For example the following template can be used to generate a table.
| Name | Index |
|------------------|---------|
<!-- ---8<--- -->
| {_NAME:case(up)} | {INDEX} |
<!-- ---8<--- -->
network load_file("./data/mississippi.net")
network render("./data/example.template")
Results:
Name | Index |
---|---|
LOWER-MISSISSIPPI | 0 |
UPPER-MISSISSIPPI | 1 |
MISSOURI | 2 |
ARKANSAS | 3 |
RED | 4 |
OHIO | 5 |
TENESSEE | 6 |
Of course, there are better ways to generate table than this, but this shows how flexible the template system is.