Templates inside templates

A template can stand in for another one. Keep the admin folder, the set of contract documents or the source layout in a template of its own, use it from all the others, and a change to it lands everywhere at once instead of in whichever copies you remember to edit.

Embedding a template

Select the folder you want it to appear in - or nothing, for the top level - and use the Template button in the toolbar. The Embed a Template picker lists the templates that can go here, and searching filters them by name and description.

The Embed a Template picker listing the templates that can be embedded here
The Embed a Template picker listing the templates that can be embedded here
Only templates that cannot create a loop are offered.

What appears on the canvas is a single card, not a copy of the other template's contents. The card is a reference: the other template is looked up when this one is deployed, so you always get its current version, not a snapshot taken the day you added the card.

Where the embedded contents end up

No wrapper folder is created

The embedded template's root folders and files are created directly where the card sits. If Client Admin contains Billing and Correspondence, you get Billing and Correspondence - not a Client Admin folder with them inside.

The card's own name is a label for the editor and nothing more. It starts as the name of the template it points at, and you can rename it to whatever reads best on the canvas; it never reaches disk. If you do want a folder around the contents, make one in the host template and put the card inside it.

Placeholders from embedded templates

The deploy prompt asks for the placeholders of the template you are deploying and those of every template it embeds, following references all the way down. Nothing is left unfilled because it was defined a level away.

Where the host template and an embedded one define the same placeholder key, the host's definition is the one used - its label, its default, its type. The same is true of global placeholders, which are only offered for keys a template actually uses, embedded templates included.

Value presets fill by placeholder key, so a preset that sets {{client_name}} fills it inside an embedded template too.

Changing or repointing a reference

Select the card and the inspector shows what it points at. Builds names the template, and clicking that name opens it. Change Template… points the card somewhere else without disturbing anything around it.

If the template it pointed at has been deleted, the panel says Template Not Found and the button reads Choose Template… instead. Deploying stops with an error rather than silently leaving that part of the structure out, so pick another template or delete the card before you deploy again.

Why loops are refused

A template cannot contain itself, directly or through a chain that leads back to it. Prefab stops this twice over:

  • The picker leaves out any template that would create a loop, and the Template button is greyed out when that leaves nothing to offer.
  • Deploying checks again as it builds, and stops with an error rather than recursing.

The second check exists because templates change after the fact. A template that was safe to embed last month can become a loop when something else is edited, and the deploy path is the last place that can catch it.

Sharing a template that embeds others

Exporting a template as a .prefab file carries the templates it embeds along with it, and importing rewires each reference to the copy that arrived. A template that nests three deep still works on the other machine, whichever system it runs. See Sharing templates.