I use a big repo for all my notes in Uni. I have a custom template for it that resides in the root folder of said repository. Until update 0.6.0 I was able to just import that template from everywhere in the repo. Now I'm not anymore. The only way it's possible to do this after this update that I can think of is manually installing my template as a local package. That's possible, but doesn't feel right. Is there a simpler way to mark a folder as a root for a project other than specifying it with the --root flag or the environment variable? For example having the typst.toml file not only act as an entry point for packages but also for what is basically a collection of papers/scripts?
#Using a repo-local template after update 0.6.0?
21 messages · Page 1 of 1 (latest)
I'm in the same situation. Absolute paths are now invalid. Relative paths outside the root of main .typ file are also invalid.
We can copy-paste the template everywhere, but that's not a good solution.
One (maybe only one unfortunately) alternative is to create a local package in
{data-dir}/typst/packages/{namespace}/{name}-{version}/
eg: {data-dir}/typst/packages/local/template-1.0.0/
where {data-dir} is
$XDG_DATA_HOME on Linux
~/Library/Application Support on macOS
%APPDATA% on Windows
Import using #import "@local/template:1.0.0": *
If you use VSCode, the LSP server and live preview extension haven't caught up to changes. typst compile will work.
Detailed instruction
https://github.com/typst/packages
Sample package (to figure out package structure)
https://github.com/typst/packages/tree/main/packages/preview/quill-0.1.0
Yeah the manual install I thought of too but it feels cumbersome
And the vscode extension has not yet caught up to the changes
For now, --root is the intended way to achieve this setup.
for now
Any spoilers you’re able to give for future plans?
No future plans. I just worded it this way to not make an absolute statement. It could change in the future but there are no plans in this direction.
Can you please explain how to use the --root method. Every time i use it in the command line it tells me error: input file must be contained in project root.
the root should point to a directory that is the "root" of the particular project you're working with
by default it's the working dir of the file you compiler, you can use that option you put it "higher" on the tree but you can't use it for unrelated folders
Got it! Makes sense now.
Just out of curiosity, was this breaking change implemented for security reasons ? It was really cool to have a local template and import it regardless the project root path.
partially security reasons, and partially because it was was merging a number of usecases into one feature and didn't really make sense
in particular because you can absolutely have local packages for your templates now
To return to old behavior, you can just --root /
But I would advise against that in general
wouldn't the old behaviour be --root $(pwd) ?
I mean like being able to access any file ever
…Also I’m pretty sure that’s the current default
Well kind of