UPDATE
- 2023/11/05: Added “Apply Template” section below with example action for applying template to an existing draft.
- 2023/03/09: Added “Placeholder” example actions discussion below to support navigation between
<|field>
fill-in placeholders in the resulting template.- 2021/09/01: Updated action to support a “Omit First Line in New Draft” option, that allows you to use a friendly name for the template in the first line, like “Meeting Notes Template” that helps when selecting templates in the prompt, but will no be included in the output.
- 2020/11/01: The current version of this action has been updated with new features, such as cursor placement, as of Nov. 1, 2020. You may need to reinstall the action from the directory if you have a previous version installed.
It is often handy to create a new draft based on some boilerplate template content to ease the creation of meeting notes, lists, or other content with a repetitive structure. The New Draft with Template example action provides an easy way to do this based on templates maintained in other drafts. Let’s briefly discuss how to use this action to maintain a robust template system in Drafts.
Install the Action
Visit the New Draft with Template action in the Action Directory on a device with Drafts installed. Tap the “install” link to install the action and Drafts will launch and prompt you to complete the install. If you have the action already, you should repeat this and choose to update your existing installed version.
Create Templates
For the “New Draft with Template” action to work, you must first create one or more templates. Do the following:
- Create a new draft. Put in the text content you want to use as a template for new drafts in this draft.
- Make sure the first line (title) of the draft is something identifiable, as it is used to identify the template when the action is run.
- Assign the tag “template” (singular) to the draft.
- Assign any additional tags desired. When a new draft is created using a template, any tags (other than “template”) will be assigned to the new draft. So, for example, your “Meeting Notes” template might also have a “meeting” tag, so it will automatically be filed correctly.
- Repeat for any additional templates you wish.
These template drafts can be in the archive or inbox, but I recommend moving them to the archive to avoid cluttering your inbox. Templates can also be flagged. When the action is run, the prompt to select a template sorts based on the text of the draft but also sorts flagged templates to the top of the select list, so if you flag often-used templates, they will appear first.
Using Template Tags
Template drafts can also contain drafts tags. Tags will be evaluated when new drafts are created using the template, so are great for inserting dynamic time stamps. If you are new to using tags in Drafts, this is a great guide.
Run the Action
Once you have created one or more templates, run the New Draft with Template action. You will be prompted to select from a list of all your templates. This list is dynamically generated by finding all drafts assigned the tag “template.” So, at any time you can add to or remove templates from the options simply by adding or removing the “template” tag from drafts.
After you select a template, the action will do the following:
- Create a new draft with the content of the template
- Assign any additional tags (and syntax) from the template to the new draft.
- Load the new draft in the editor, ready to edit.
Fill-in Placeholders
Often, you may have one or more values you want to fill in in a template after creating it. This action, along with the two companion actions below, make it easy to do that by creating fill-in placeholders in the template in the format <|fieldname>
(fieldname
is optional, <|>
will work also, but the field name allows you to notate what to fill-in).
If any placeholders in this format are found in the template after creating a new draft, this action will locate the cursor at the first placeholder, ready for you to type the replacement text.
If you have templates with more than one placeholder, install the sample actions below to get an easy way to navigate through placeholder in a draft to insert new values. When used, they will move the text selection to the next (or previous) placeholder, ready for you to type the replacement text.
- Previous Placeholder: Find previous
<|>
style placeholder and select its text. Default keyboard shortcut:control-command-up arrow
. - Next Placeholder: Find next
<|>
style placeholder and select its text. Default keyboard shortcut:control-command-down arrow
.
An example of use for placeholders might be in a “Meeting Notes” template, where you would have a template like:
Topic: <|topic>
Attendees: <|attendees>
# Notes
<|notes>
After creating a new draft, the draft would be open in the editor with <|topic>
as the selected text, ready for you to replace that value. You could then use the next/previous placeholder actions to move the selection to each value to complete the new draft.
Manage Templates with a Workspace
Note: You can create the workspace described below manually or install a sample “Templates” workspace from the directory.
If you plan to use this action, it’s a great idea to create a “Templates” workspace to keep up with your templates so you can easily update them as needed. I recommend configuring the workspace with the following options:
- Tag Filter:
template
- Archive Sort Order:
Text - Ascending
- Archive - Sort flagged to top:
On
- Select Archive : To automatically switch to the archive when loading the workspace. This allows you to store your templates in the archive, so they do not clutter your inbox.
When you need to edit your templates, you can open this workspace to access them all in one place easily.
Widgets!!!
The “New Draft with Template” action is great for use with iOS Widgets! Add the action to a grid widget on your Home Screen, and you can quickly jump straight into Drafts with a new draft based on one of your templates ready-to-go.
Applying Template to Existing Drafts
Sometimes you realize you want to use a template after you have started on a draft. We also provide an example Apply Template action, which can be used to apply the tags, syntax, and content from one of your templates to the current draft.
When run, this action will prompt to select the template, and instead of creating a new draft, it will:
- Assign tags from the template to the current draft
- Assign syntax from the template to the current draft
- Insert the content of the template in the current draft as follows:
- If a
<|>
placeholder exists in your template, the content of the current draft will replace that placeholder in the new content. This allows a template to have content both before and after where the current content is inserted. - If no
<|>
placeholder exists, the template content will be inserted before the current content of the draft.
- If a
Summary
With a few simple steps and just one action, you can manage a robust template system in Drafts. Have special requirements? Use this example as a starting point to modify to suit your needs.