How Prefab thinks

Prefab has four moving parts: templates, placeholders, actions and watched folders. This page says what each one is and where one ends and the next begins.

Templates: a shape, not a copy

A template describes a folder structure - which folders, which files, what is inside those files. Deploying it builds that structure somewhere on disk. Nothing is carried over from a previous project, so nothing arrives that has to be deleted.

Templates live in your library. Editing one changes what future deployments look like. Folders you have already made are yours, and Prefab does not go back and touch them - the one exception is watched folders, which you opt into folder by folder.

Placeholders: the parts you fill in at deploy time

Write {{client_name}} in a folder name, a file name, or inside a file, and you have asked Prefab a question. It puts that question to you when you deploy, and your answer goes into every place the placeholder appears.

Three words come up throughout these pages. The placeholder is what you write into the template. The key is the name between the braces, client_name. The value is what you type at deploy time. Each placeholder also carries a label, which is the wording the prompt uses above its field.

A placeholder has to be defined before Prefab will ask about it. Definitions live in the template's Placeholders tab, and a key nothing defines is left on disk exactly as written, braces and all. Four keys are the exception: {{date}}, {{year}}, {{author}} and {{folder}} answer themselves, never appear on the prompt, and need no definition. See Using placeholders.

You can define them later

Type a placeholder into your structure first. Prefab notices keys nothing defines and lists them under Suggestions at the foot of the Placeholders tab, with a Create button beside each.

Actions: what a template does as well as contains

An action is attached to a folder or a file in the structure, and it carries a trigger - the When It Runs choice in the action editor - that decides when it happens.

On deploy actions run once, as that folder or file is created: initialise a git repository, reveal the folder in FinderFile Explorer, open it in an app.

Watch the folder actions run later, on files that land in the folder after it exists. This is the trigger that turns a plain folder into a watched folder.

Globals: definitions shared across the library

Placeholders, actions and value presets can each be defined once for your whole library instead of per template. They live in the Globals screen, alongside Library and Settings in the sidebar.

A template's own definition always wins. A global placeholder is only offered for a key the template writes but has not defined itself, and a global action is only used where the template does not carry its own copy of that action. So a template that already defines something keeps behaving exactly as it did.

Where Prefab keeps your templates

Templates are stored where the app and its right-click menu can both reach them, so right-clicking in FinderFile Explorer sees the same library the app does. Files a template deploys that are not plain text - images, documents, archives - are kept in the same container and written out byte for byte when you deploy.