Templates
Templates are Typst (.typ) files with optional JSON metadata files. They are stored in the templates/ directory of your data folder.
Creating a Template
Using the UI
- Click "New Template" on the Dashboard
- Enter a template name (e.g.,
my-report) - Write your Typst markup in the editor
- Use the Preview tab to see real-time PDF output as you type
- Click Save
Using the API
bash
# Create template content
curl -X PUT http://localhost:3000/api/templates/my-report \
-H "Content-Type: text/typst" \
-d '#let data = json.decode(sys.inputs.at("data"))
= #data.title
#data.body'Template Metadata
Each template can have an associated JSON metadata file (saved as template-name.json alongside the .typ file):
json
{
"title": "My Report",
"description": "A sample report template",
"exampleData": {
"title": "Hello, World!",
"body": "This is a sample report."
}
}Folder Organization
Templates can be organized in nested folders:
templates/
├── universal-template.typ
├── universal-template.json
├── student/
│ ├── student-card.typ
│ └── student-card.json
└── academy/
├── enrolled-by-career.typ
└── students-by-condition.typFolders are created automatically when you save a template with a path separator (e.g., academy/enrolled-by-career).
Typst Variables
Data passed to templates is available as Typst variables. The full JSON object is available via sys.inputs:
typst
#let data = json.decode(sys.inputs.at("data"))
#let title = data.title
#let date = data.date
#let items = data.itemsBest Practices
- Use the helper library for common patterns like tables and date formatting
- Keep templates focused on layout and styling, not data processing
- Use meaningful variable names in your JSON data
- Test templates with the live preview before generating reports
- Use subfolders to organize templates by project or report type