Sharing templates

A template can be saved as a .prefab file: one document holding the template and everything it needs to work on a machine that has never seen it. Send it to a colleague, keep it in a repository, or use it to move your own library to a new machine.

Exporting

Right-click a template in the sidebar and choose Export as File…, or select the template and use Export Template… (⇧⌘ECtrl+Shift+E). Prefab suggests the template's name and saves a .prefab document wherever you point it.

The save panel exporting a Prefab template as a .prefab file
Windows screenshot coming soon
One file, whatever the template contains.

What travels with it

A .prefab file is a compressed archive holding a manifest and a copy of every file the templates deploy. Exporting one template carries:

  • The template itself. Its structure, file contents, Finder tags, folder icons, placeholders and actions, including any watched-folder rules it defines.
  • Templates it embeds. A template that uses another as a building block would arrive broken without it, so those are carried too and their references are re-pointed on import.
  • The files it deploys. Anything that is not plain text - images, .psd, .docx, a binary starter file - is stored in the archive byte for byte. Files are identified by their content, so the same file used in three places is stored once.
  • Global placeholders it relies on. Only the ones the template writes without defining itself. The rest of your library's globals stay behind.
  • Global actions it attaches. An action on a folder points at its definition by identity, so the definition has to travel or the action would arrive with nothing to run.

What does not travel: remembered values, value presets, the registrations of folders Prefab is already watching, and the folder permissions you have granted. Those belong to a machine, not to a template.

Importing

On the receiving machine, any of these work:

  • Double-click the .prefab file. Prefab is registered as the owner of the file type.
  • Drag it onto the Prefab window or its Docktaskbar icon.
  • Import Template File… (⇧⌘OCtrl+Shift+O), which accepts several files at once.

Prefab reports what arrived: the templates it imported, how many included files were added, how many embedded templates came along to satisfy a reference, and any global placeholders or global actions that were installed. The imported template is selected in the sidebar, ready to deploy.

Prefab's import summary listing the template imported and the files added with it
Windows screenshot coming soon
The summary separates what you chose to import from what was carried along with it.
An import never overwrites what is already there

Every imported template is given a fresh identity, so it is added alongside your existing templates rather than replacing one, even if it started life on this MacPC. References between the carried templates are re-pointed to match. A global placeholder whose key you already use keeps your local meaning, and a global action already in your library is left alone.

What the other machine still has to do

A template travels with its actions, but not with permission to carry them out. Two things are set per machine and per person:

  • Terminal commands. A template whose actions run git init or npm install needs terminal commands switched on and the shell runner installed on the receiving Mac. See Terminal commands.
  • Folder access. Prefab asks for access to a folder the first time it is told to write there, whoever made the template.

Watched-folder rules arrive with the template and start working when it is deployed on the new Mac, which registers a folder there. Folders being watched on your Mac stay yours.

When something is missing

If the archive was written by a newer version of Prefab than the one reading it, the import is refused rather than half-done. The file's format version is checked before anything is installed.

If a file the template deploys could not be read out of the archive, the import still succeeds and says how many are missing. Those entries deploy as empty files until you point them at a source again. See Files and contents.