Drafts Reference

Templates and Tags

Drafts has a lightweight template engine to allow control over how text is output in action steps. Templates are used for most values in action steps, so can be used to not only create the content of an exported file, or mail message, but to dynamically create the file name and folder, assign tags, insert timestamps and more, when an action is run.

Content Tags

Identifier Tags

Dates and Locations

Utility Tags

Custom Tags

In addition to the predefined tags always available, scripts in an action can create custom tags which become available to action steps run after the script in the same action. This is useful if a scripted action step processes text to create a value that then needs to be inserted in a later step that shares that text. The below example shows a simple script with creates a tag.

let s = "My String Value";
draft.setTemplateTag("mytag", s);
// after running this script, templates later
// in the action will have available a [[mytag]] tag.

See Draft object documentation for more details.

Other Special markup

Escaping

If you want to use something which would otherwise be evaluated as a template tag or function but not have it evaluated in actions, it needs to be escaped by placeing a single backslash () character before it. So, for example \[[title]] would be ignored and not replaced with the title of the draft. The escaping backslash would be removed, however.