go-typst/examples/passing-values
David Vogel 1aa13dbfb5
Some checks failed
test / test non-docker (1.23.x, 0.12.0) (push) Failing after 4s
test / test non-docker (1.23.x, 0.13.0) (push) Failing after 3s
test / test non-docker (1.23.x, 0.13.1) (push) Failing after 4s
test / test non-docker (1.23.x, 0.14.0) (push) Failing after 3s
test / test docker (1.23.x, ) (push) Failing after 23s
test / test docker (1.23.x, ghcr.io/typst/typst:0.14.0) (push) Failing after 15s
test / test docker (1.23.x, ghcr.io/typst/typst:v0.12.0) (push) Failing after 20s
test / test docker (1.23.x, ghcr.io/typst/typst:v0.13.0) (push) Failing after 19s
test / test docker (1.23.x, ghcr.io/typst/typst:v0.13.1) (push) Failing after 21s
Update README.md & Cleanup
2025-11-16 18:15:25 +00:00
..
main_test.go Rework passing-values example 2025-02-27 16:07:34 +01:00
main.go Update README.md & Cleanup 2025-11-16 18:15:25 +00:00
output.pdf Rework passing-values example 2025-02-27 16:07:34 +01:00
README.md Rework passing-values example 2025-02-27 16:07:34 +01:00
template-preview.typ Rework passing-values example 2025-02-27 16:07:34 +01:00
template.typ Rework passing-values example 2025-02-27 16:07:34 +01:00

Passing values example

This example demonstrates how to pass values to Typst, which can be useful in rendering custom documents such as reports, invoices, and more.

How it works

This example follows the template pattern described in the Typst documentation. Here is a short overview of the files:

  • template.typ defines a Typst template function that constructs a document based on parameters.
  • main.go shows how to convert/encode Go values into Typst markup, and how to call/render the template with these converted values.
  • template-preview.typ also invokes the template while providing mock data. This is useful when you want to preview, update or debug the template.