How to include files inside template/package, but parsed from project path?

You don’t need include-files function as it’s a simple oneliner:

#let files = ("a.typ", "b.typ", "c.typ")
#files.map(x => include x).join()

This is actually a pattern that works something like this:

#for item in items [#item content]
// is
#items.map(item => [#item content]).join()

for loop joins the result of its block execution iterations.

Also, I don’t see the point in making before a dictionary over array.


I don’t understand the error as some context was stripped away. What is the root directory of the project during compilation?

This works fine for me:

local/test-template/0.1.0/
├── sections
│   └── preface
│       ├── acknowledgement.typ
│       ├── contents.typ
│       ├── preface.typ
│       └── readers_guide.typ
└── src
    ├── main.typ
    └── template.typ

typst c --root . src/main.typ

test-template.zip

1 Like