When rendering a file, pass a variable to the --input of Typst with the file name (and it's directory) so that it may be accessed with sys.inputs in the code.
One line change:
typst --input main=fileToBeRendered.typ . . .
Use Case
This simple change allows control flow based on the file being rendered. This is especially useful for large projects, which may be split into several chapters but that you may wish to have more control over while simultaneously saving performance in such a situation. Thanks to sillyfreak on Discord for coming up with this solution.
if sys.inputs == "main.typ" {
// Yay control flow!
}
Description
When rendering a file, pass a variable to the
--input
of Typst with the file name (and it's directory) so that it may be accessed withsys.inputs
in the code.One line change:
Use Case
This simple change allows control flow based on the file being rendered. This is especially useful for large projects, which may be split into several chapters but that you may wish to have more control over while simultaneously saving performance in such a situation. Thanks to sillyfreak on Discord for coming up with this solution.