Drafts 32.0

What’s New

Action Bar Tint Colors

For those who are fond of using color to distinguish items on screen, there is now an option to use action tint colors in the Action Bar. To enable on iOS, scroll to Action Bar options in Aa editor settings. On Mac, toggle menu item in Action Bar’s group selection drop-down menu.

It is sometimes useful to output a date that is relative to another date (usually the current one), adjusted by some time interval. It has always been possible in script to create and adjust future and past dates, but now it is easier with the addition of a new method to adjust dates using simple date math expressions.

This begins with a new way to create related date expressions, which consist of a list of plus or minus time intervals which can applied to a date. Each expression look like (+|-)(integer) (unit), and can be combined in a list to make multiple adjustments to a date. A couple of quick examples:

Units supported are: year, month, day, hour, minute, second. Units can be used in either singular or plural forms.

These expressions can be used in JavaScripts with the adjustDate(date, expression) function, or by providing an additional expression argument, along with the strftime formatting argument, in template tags which work with date. Those tags are the 2022-09-20, 2022-09-20-14-51-18, [[created]], and 2022-05-03 tags. Again, by example:

Adjustment expressions are calendar-aware, such that adding 1 month to May 31 would result in June 30, since June does not have a 31st.

A couple of ready to use examples:

Mustache Templates

Drafts templates, with their square-bracket, # Drafts 32.0 -style tags are still the default throughout actions, but with this update we have introduced the option to use an alternate template engine based on Mustache templates.

Mustache templates provide some additional power, like the ability to have conditionally rendered blocks, loop over arrays, insert information from other drafts, as well as more powerful filtering options. For details, see the Mustache documentation.

Mustache templates are available as a option on all long-form templates in action steps, can can also be triggered via script using the draft.processMustacheTemplate function.

Using Mustache Templates for Safari Web Capture

If you often capture using the share extension and Safari, you might be interested in switching your web capture template ] to use Mustache. This has the advantage of being able to use conditional sections to only render part of the text template for the captured text selection /if/ a selection exists.

Improved Template Editing

Drafts now includes basic syntax hightlighting definitions for both Drafts templates, and the new Mustache templates. When editing long-form templates in actions steps, the templates can now (optionally) be opened in an editor with syntax highlighting and basic autocomplete for common tags. Use the edit button by the template in the action editor to open the template editor.