TIP: Creating New Drafts with Templates


It is often handy to create a new draft based on some boilerplate template content to ease the creation of meetings notes, lists, or other content with 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 (iOS) device with Drafts installed. Tap the “install” link to install the action.

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 be used as a template for new drafts.
  • Make sure the first line (title) of the draft is something identifiable, as it will be 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 from the 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 away properly.
  • 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. The can also be flagged. When the action is run it 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.

NOTE: Template drafts can also contain drafts tags. They will be evaluated when new drafts are created using the template, so are great for inserting dynamic time stamps

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 template, the action will do the following:

  • Create a new draft with the content of the template
  • Assign any additional tags from the template to the new draft
  • Load the new draft in the editor, ready to edit.

Make a Template Workspace

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 archive when loading workspace.

When you need to edit your templates, you can open this workspace to access them all in one place easily.


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.



This is very useful. Thanks. Just one query. How can I configure the text so that the date is initiated as the current date. I have a TE snippet and it expands. What does [[date]] do? I couldn’t get that part. If you can explain how the current date will be automatically inserted, it would be might useful. Even now it is, but ironing out the date wrinkle will help. Sorry to be sounding completely naive, but I don’t have any knowledge of Java script etc.

1 Like


The drafts tags link above links to information that covers this. It isn’t JavaScript, but a feature built into Drafts itself.



This Using Drafts Templates article is the best place to start on how tags work in Drafts. This action runs the template draft through the template engine like it would be if it was a template in an action step, so all the tags will be evaluated when the action is run - in this case the new draft is empty, so it’s really only useful for time stamps.



For using the draft templates, should I change the settings from Markdown to simple text?



This looks very usefl to me. ONly I seem to have missed something becausen I do not know how to take the first step on my iPhone 8

Can you help me with that please



Actions are installed from the action directory by tapping the “Install” link, see attached. You need to be on your iPhone, in Safari, on the action page and tap “Install” - it will open Drafts and ask what action group to place the action. That’s it.



Is it possible to create a time stamp in the military time date group format (ddHHmm MMMyy or ddHHmm “Z” MMMyy)?

For example, 06/12/20 at 08:13 in the Central Time Zone is “060813SDec20”. Eastern time is “R”, Central is “S”, and so on. Frequently the time zone is omitted.



To insert a date/time in the format ddHHmm MMMyy, you can just use the date template tag with a format string like this.

The template tag and format used looks like this.

[[date|%d%H%M %b%y]]

The other format (ddHHmm “Z” MMMyy) is a bit tricker as it isn’t natively supported by strftime, but it can be achieved with a little bit of scripting. But for this reason, it does mean you can’t just drop it into a template for evaluation.

However, to provide an example as it may be useful elsewhere, here’s how I approached doing this.

It works quite similarly to the previous use of the date template tag, but it uses the JavaScript below to lookup the timezone offset identifier and then inserts the defined date/time string to the current selection and after that, jumps the cursor to the end of the newly inserted text.

let timezoneoffset = draft.processTemplate("[[date|%z]]")
let timezone = ""

switch (timezoneoffset)
	case "+0100":
		timezone = "A"
	case "+0200":
		timezone = "B"
	case "+0300":
		timezone = "C"
	case "+0400":
		timezone = "D"
	case "+0500":
		timezone = "E"
	case "+0600":
		timezone = "F"
	case "+0700":
		timezone = "G"
	case "+0800":
		timezone = "H"
	case "+0900":
		timezone = "I"
	case "+1000":
		timezone = "K"
	case "+1100":
		timezone = "L"
	case "+1200":
		timezone = "M"
	case "-0100":
		timezone = "N"
	case "-0200":
		timezone = "O"
	case "-0300":
		timezone = "P"
	case "-0400":
		timezone = "Q"
	case "-0500":
		timezone = "R"
	case "-0600":
		timezone = "S"
	case "-0700":
		timezone = "T"
	case "-0800":
		timezone = "U"
	case "-0900":
		timezone = "V"
	case "-1000":
		timezone = "W"
	case "-1100":
		timezone = "X"
	case "-1200":
		timezone = "Y"
	case "+0000":
		timezone = "Z"

editor.setSelectedText(draft.processTemplate('[[date|%d%H%M]]' + ' "' + timezone +  '" ' + '[[date|%b%y]]'))
let selRange = editor.getSelectedRange()
editor.setSelectedRange(selRange[0] + selRange[1], 0)

There seemed to be some variation in the use of spacing in the original post, so I’ve included them just in case. If not required, they can be easily removed.

Hopefully that all makes sense and helps for what you want.



My apologies for the variation in spacing, I wasn’t sure of the best way to present the “Z” to make it more readable without the spaces.

I’m in the shallow end of the gene pool when it comes to programming, where does the code go with respect to the Template action “New draft with template”?

1 Like


What is the date format if I want the date as ‘Wednesday, 10 April 2019’?



The template tag in the first example would just go directly in your template.

The second example you could run afterwards as a separate action, or you could integrate the script into an action by adding it into a script action step. That’s why I noted the second option couldn’t just be dropped in. If you have a look at the provided action above, you should see how it is included in that action. The key point here though is that this isn’t generic and presumably not something you would want to do with every template you use, so you would have to be “creative” in modifying Greg’s original action if you want to ensure it stays generic.

Given your statement above re. programming, it may simply be that, for now, using that first format is the way to go and with more experience you might come up with a good way for you to include in the original action; but in the interim you can always have the action I posted available to manually insert it if required.



You can do this as follows.

[[date|%A %d %B %Y]]

Note the references to “strftime” above. If you Google that term, you’ll find lots of information about the available options.



Ok, I installed the script in a new action group. However I believe Daylight Savings Time may be playing havoc, the date I get when running it is: 100132 “R” Apr19

I live in the Central Time zone, which is “S”, which is offset -0600, it should now be -0500. I think I can fix that.

What I’d like it to look like is: 100132SApr19. How can I remove the quotation marks?

Thank you very much for your help with this. It will indeed get me started.



Got it! Here’s the result: 100207SApr19

I know, “whoopie”.

Thanks for all your help.



Try changing

editor.setSelectedText(draft.processTemplate('[[date|%d%H%M]]' + ' "' + timezone +  '" ' + '[[date|%b%y]]'))


editor.setSelectedText(draft.processTemplate('[[date|%d%H%M]]' + timezone +  '[[date|%b%y]]'))

The time zone is picked up from your device, so yes, you may need to account for that if you are in a DST observing location when working backwards to the identifier.



This is excellent.

One thing I would like is the ability to prompt the user for non-standard template items. So the code would use a service (probably a new one) to scan the selected template and use it to pop up prompts the user would fill in.

So, for example, a template might have [[customerName]] somewhere in it and the code would detect that and prompt me for “customerName”.



this is already existing: https://actions.getdrafts.com/a/1IN credits to @dansays

1 Like


So, combining the two - the template chooser and this - would be handy.



I’ve not got time to try it this morning, but I’m wondering what would happen if you used double chevrons for the TextExpander snippet expansions and it’s fill in fields?

Unlike the action based option above, I’m curious if this would automatically trigger the capture and population of content via TextExpander?