Templating
Within the global settings of an environment, it's now possible to define templates, which generating .pdf reports. These reports can be generated from a template within the Exolynk scripting.
Creation of a Template layout
Within the global settings it's possible to create a new tempalte and open it afterwards. Within the layout tab of the template it's possible to define a template with markdown & typst syntax. Please see this documentation for more information on this.
Exolynk supports all typst funktioanlities, but the following aspects work a little bit different:
- Import Exolynk allows the import of other templates by their ident and not by filename
- Files Typst can only access files (image/data), which have been inserted via scripting before
The following fonts are available for use:
- Poppins --> Weights: extralight, semibold, regular
- Fira Math --> For math formulas & text
- Noto Emoji --> For emojii support
Template Coding
Within the template editor, the code section is used, to create a script, which is only executed for testing the template. This specific script need to return a templating object to work properly. The templating object can be enhacned with custom data or files, to make them available to the template rendering. Following an example code which adds an image and example data:
pub async fn main() {
let env = exo::get_environment();
let templating = exo::Templating::new(env);
let client = http::Client::new();
// download an image and add it as binary data
let response = client.get("http://127.0.0.1:8080/api/file/6f1b958e-843b-4ed2-89dc-41fc012373d7").send().await?;
let image = response.bytes().await?;
templating.add_file("image.jpg", image);
// add json data
let data = json::to_bytes(["A", "B", "C"])?;
templating.add_file("data.json", data);
// additional .pdf creation and download on every run
//let pdf = templating.to_pdf("main")?;
//exo::ui::download_file("test.pdf", pdf)?;
// return object for test rendering
Ok(templating)
}