Can I write information to the trace from a template?

I would like to be able to give a warning message from a template, but still generate the document. With assert, a message is generated, but the document is not generated. Can warnings be inserted into the track?

You could use panic.

With panic the document is not generated, I want the document to be generated giving a warning to stop using functions that I am going to remove in the template in the future.

This is not currently possible. If you’re debugging something, note that, when using the web app (or VSCode I think), you can hover over variables in your code to see the values they take, so you can create a variable with the contents of what your “warning” would be and hover over it to see its value(s) across each layout iteration. If you’re not debugging and you just want to warn users, unfortunately you’re out of luck for the moment. There’s some discussion here: Logging function for debug output · Issue #1669 · typst/typst · GitHub

2 Likes