#Using a repo-local template after update 0.6.0?

21 messages · Page 1 of 1 (latest)

humble kernel
#

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?

austere skiff
#

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

GitHub

Packages for Typst. Open for submissions now. Contribute to typst/packages development by creating an account on GitHub.

GitHub

Packages for Typst. Open for submissions now. Contribute to typst/packages development by creating an account on GitHub.

humble kernel
#

Yeah the manual install I thought of too but it feels cumbersome

#

And the vscode extension has not yet caught up to the changes

zealous cairn
#

For now, --root is the intended way to achieve this setup.

humble kernel
#

for now
Any spoilers you’re able to give for future plans?

zealous cairn
#

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.

unborn dagger
round solar
#

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

orchid pond
#

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.

round solar
#

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

dire hamlet
#

But I would advise against that in general

round solar
#

wouldn't the old behaviour be --root $(pwd) ?

dire hamlet
#

…Also I’m pretty sure that’s the current default

#

Well kind of