templates
Adds macro templates shipped as files inside the extension folder.
Details #
A template is a ready-made macro that comes with your extension. It is a normal macro saved as a JSON file in the extension folder. Switchboard reads the file and lists it as a starting point, so people can begin from your macro instead of an empty one.
Declare it in switchboard.json under adds.templates. Every entry has an id (lowercase, digits and . _ -, up to 64 characters, starting with a letter), a title (1 to 80 characters), a file and an optional description. Ids must be unique within the list. The description is the template's summary.
{
"adds": {
"templates": [
{ "id": "daily-note", "title": "Daily note", "file": "templates/daily-note.macro.json" }
]
}
}
The easiest way to get the file is to build the macro in Switchboard and export it as JSON. Give it an id of its own (a UUID).
Gotchas #
The engine reads the file when it lists templates. A file that is missing, not valid JSON, larger than 1 MB or outside the folder (a link out of it counts) is left out without an error. Run
switchboard ext check .to catch this.The macro is used as written. Every
{{name}}it reads must be an input or an earlier step's result.Unknown keys in an entry are refused.
Full example #
The Full example above is a working extension with two templates, and a test that opens both macro files. You can download it from the Full example section and edit it into your own.