Tags to run actions?

Hi!

On my quest to replace TextExpander (specially on iOS) with built-in Drafts features, I’m struggling with how to imitate some TextExpander macros that run some JS as part of the expansion.

For example, I have one that creates a template for review emails, that has this format

---
title: Weekly Report  %snippet:;wsfriday%
date: %Y-%m-%d
to: [EMAIL ADDRESSES]
---

Weekly Report for week %date:ww%, ending %snippet:;nxtsun%

And the interesting parts are:

%snippet:;wsfriday% runs a TextExpander Macro that is a JS that gets the date of “next Friday” (example output: Aug. 01, 2025)

%snippet:;nxtsun%: Similar but gets next Sunday date (example: August 03, 2025)

And %date:ww% provides the week number of current week (31)

I can create an expansion using tags that give me the rest of the data (for example the date: line), but not for these three things (specially the weekdays dates)

What’d be the best approach to get something like this that I could run/insert in another draft?

Thanks!

You probably want to start with an action that creates a new draft based on templates, like in this tip.

Template tags in Drafts support relative dates, but not pinning to specific dates like you are asking for, so you’d want to add a script step that calculates the date and sets custom template tags for those values using draft.setTemplateTag.

Hopefully, that will get you on the right track.

Just chiming in, I’ve done something similar by adding a script step that calculates the next Friday or Sunday, then uses draft.setTemplateTag() to inject the values into the template. Works pretty well if you run the action from a keyboard shortcut or action bar. Let me know if you need a code example.