Render Engine

A reporting service

The /Templates endpoint renders templates in any format using the Apache FreeMarker®.

Apache FreeMarker® is a template engine: a library to generate text output (HTML web pages, e-mails, configuration files, source code, etc.) based on templates and changing data. Templates are written in the FreeMarker Template Language (FTL), which is a simple, specialized language... .

How it works: FreeMarker

Imagine you have any document that contains placeholders - which we call a template:

Hello ${UserName}
Welcome to the Freemarker render engine.

And you have the data, which you want to insert into this template, to make it a document.

{
    "UserName" : "Markus Schmidt"
}

We call the process to fill out the template: render a template.

render( Template, Data) ⇒ document

Example

POST {{host}}/templates/render?templateName=...

{ "UserName" : "Markus Schmidt" }

--- response ---

Hello Markus Schmidt!
Welcome to the Freemarker render engine.
The Basics

Render Example

Apache FreeMarker® is a powerful and proven open source library to render documents. Here is a second, more complex example, about what to expect.

Imagine you want to send a formatted HTML e-mail in case of an error. Here's the FreeMarker template, containing placeholders:

<h1>Error Details</h1>

<p>Execution Id : ${execId}<br/>
Trace Id : ${traceId}<br/>
Time-Stamp : ${dtUtc}</p>

<h2>Errors</h2>
<#list errors as err>
<p>Filename=${err.filename}<br/>
<b>RecId=${err.recordId}</b>: <i>${err.message}</i>
<p />
</#list>

In case of an exception you have the following dataset that you want to use to render a nice e-mail:

{ 
    "execId" : "4711",
    "traceId" : "0AF7-D309",
    "dtUtc" : "2024-05-02T13:00:00.123",
    "errors" : [
        { "recordId" : 1000, "filename" : "File01.csv", "message" : "Missing zip-code."},
        { "recordId" : 2001, "filename" : "File02.csv", "message" : "Missing street."},
        { "recordId" : 2103, "filename" : "File02.csv", "message" : "Invalud amount."}
    ]
}

The output

<h1>Error Details</h1>

<p>Execution Id : 4711<br/>
Trace Id : 0AF7-D309<br/>
Time-Stamp : 02.05.2024 13:00:00</p>

<h2>Errors</h2>
<p>Filename=File01.csv<br/>
<b>RecId=1000</b>: <i>Missing zip-code.</i>
<p />
<p>Filename=File02.csv<br/>
<b>RecId=2001</b>: <i>Missing street.</i>
<p />
<p>Filename=File02.csv<br/>
<b>RecId=2103</b>: <i>Invalud amount.</i>
<p />
Rendered data in the browser

Last updated