kickstart icon indicating copy to clipboard operation
kickstart copied to clipboard

Allow using all of Tera's features (macros, includes, etc.)

Open TECHNOFAB11 opened this issue 1 year ago • 1 comments

When having a single repo with multiple templates for example it would be cool to have access to all the advanced features of Tera, like macros, blocks, includes etc.

Currently everything is rendered using one_off, thus no includes etc. work. It might be possible to just pass the root path of the repo to Tera, not sure what the performance implications are when the repo is quite big (if Tera loads these files no matter what it would be hell, but if they're only loaded on demand anyways it should be fine). That way something like that would be possible:

|- templates
|   |- <templatename>
|   |   |- flake.nix
|   |   |- template.toml
|- utils/shared/common whatever
|   |- flake.nix

And then be able to {% extend "utils/flake.nix" %} in templates/<name>/flake.nix. This way files and contents which are shared across templates could be pulled out to a single path, making maintenance easier :)

Repos containing just a single template could benefit from this aswell, as these features could still be used (the imported files just have to be added to ignore so they're just used by Tera)

TECHNOFAB11 avatar Dec 18 '24 13:12 TECHNOFAB11

I'm not too sure about that, since it becomes tricky to see the difference between the template files and the files used just to generate the templates. I'll need to think about it

Keats avatar Dec 20 '24 10:12 Keats