Help incorporating a template tag with an action script

I’ve installed this action from the directory:

https://actions.getdrafts.com/a/1VE

It sends the draft to Ulysses as a new sheet.

I want to adapt it so that it uses a template tag, defined in the step before the script. Currently it just sends the raw draft.

For reference, my template tag is [[allofit]] and the template:

# [[title]]
[[body]]

The end result I’d like is that the first line of the draft will have markdown for H1, followed by the remainder of the body of the draft.

I’ve tried a few things that haven’t worked, but my knowledge of javascript is very limited.

Thank you for your help.

I think just changing

cb.addParameter("text", draft.content);

to

cb.addParameter("text", "# " + draft.content);

might do what you want without the need for a template.

Otherwise, perhaps this.

cb.addParameter("text", draft.processTemplate("[[allofit]]"));

Yes! Your first suggestion did it.

Huge thanks!