mirror of
https://github.com/Dadido3/go-typst.git
synced 2025-04-18 15:13:16 +00:00
This changes the example to use the template pattern; we now have a single Typst file containing a template function. Instead of loading and rendering the template, we will now generate temporary Typst markup that will import the template function and call it with custom data. This also means that it's pretty easy to test, preview and debug the template.typ outside of go-typst. All that is needed is another Typst file which will call the template with mock data. Also, we now use Compile instead of CompileWithVariables and inject encoded Go values into our temporary markup.
17 lines
179 B
Go
17 lines
179 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// Run the example as a test.
|
|
func TestMain(t *testing.T) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
t.Error(r)
|
|
}
|
|
}()
|
|
|
|
main()
|
|
}
|