Managing Templates
Templates define how your documents look. They are version-controlled and support powerful logic.
Template Types
HTML / SVG
Standard web technologies. Use HTML for most documents and reports. Use SVG for labels where precision and scaling are critical.
Draw.io Integration
For SVG templates, Thoth includes an integrated Draw.io editor.
-
Set the Template Type to
HTML, SVG, Draw.io. -
Click Open Editor.
-
Design your label visually.
-
Use the
Texttool to add placeholders like{{ barcode }}. -
When you save, the SVG source is automatically updated and "cleaned" to be compatible with the rendering engine.
Templating Engine (Jinja)
Thoth uses a syntax inspired by Jinja.
Variables
Inject data using double curly braces:
<div>Customer: {{ customer_name }}</div>
Conditionals
Show or hide content based on data:
{% if priority == 'high' %}
<span style="color: red;">URGENT</span>
{% endif %}
Loops
Iterate over lists:
<ul>
{% for item in line_items %}
<li>{{ item.name }} - {{ item.quantity }}</li>
{% endfor %}
</ul>
Filters
Transform data on the fly:
<div>Total: {{ total_price | currency('USD') }}</div>
<div>Date: {{ created_at | date('YYYY-MM-DD') }}</div>
Versioning & Publishing
Templates follow a Draft/Published workflow.
- Draft: Any change you save creates a new state in the current draft.
- Publishing: Clicking Publish takes the current draft and creates a permanent, immutable Version.
- Stability: Renderers use the latest Published version by default. This ensures that editing a template doesn't break production documents until you are ready.
- Rollback: You can view the History tab and click Restore on any previous version to bring its content back into the current draft.
Variable Detection
When you save a template, Thoth parses the source code to find all {{ variable }} tags. These detected variables are then used:
-
In the Renderer to let you map data sources.
-
In the Preview dialog to generate input forms.