Managing Renderers
The Renderer is the core component that orchestrates document generation. It brings together a Template and one or more Datasources.
1. Selecting a Template
When you create a Renderer, you first select a Published template. The template's detected variables will be displayed in the Mapping section.
2. Associating Datasources
You can add multiple datasources to a single renderer. Each associated datasource must be given a unique Alias (e.g., user, order, company). This alias is used to reference the data fields in the pipeline and mapping.
3. The Pipeline (Data Chaining)
The Pipeline allows you to pass data from one datasource into another.
Example Scenario:
-
DS1 (Alias: 'order'): Fetches order details byorder_id. One of its outputs iscustomer_id. -
DS2 (Alias: 'customer'): Fetches customer details byid.
Pipeline Configuration:
In the configuration for customer, you can map its id parameter to order.customer_id.
When the renderer executes:
- It first calls the
orderdatasource using the externalorder_idinput. - It takes the
customer_idfrom the result. - It calls the
customerdatasource using that ID.
4. Template Mapping
This section links your data to the visual template. For every variable detected in the template (e.g., {{ name }}), you can:
-
Map it to a datasource field:
user.full_name. -
Leave it as an External Input: The value must be provided when calling the render API.
-
Use a static value.
5. External Inputs
Any parameter or variable that is NOT mapped to a datasource output property becomes an External Input. These are the values your application must send to Thoth when it requests a document generation.
6. Execution & Testing
-
Render (Preview): Allows you to enter sample data for all External Inputs and see the resulting HTML/SVG/PDF in the browser.
-
Print: Allows you to send the generated document to a physical printer via a Printing Client.
7. Versioning
Like templates, Renderers support versioning.
-
Draft: Your working configuration.
-
Published: A snapshot used for production.
-
API Access: When calling Thoth via API, you can specify if you want to use the
PUBLISHEDversion (default) or a specific version number.