Insert line break in script

I’m using this line in a script that sends a Draft to iOS Reminders.


let notes = draft.processTemplate("[[body]]" + " " + "(Created [[created|%Y-%m-%d]])");

I would like to insert a line break so the “created on date” appears at the end of the note, on its own line. Can anyone help?

There’s a couple of ways to do it. In a literal string (between double quotes) in Javascript, you use the \r escaped character to create a line break, like:

draft.processTemplate("[[body]]" + " \r" + "(Created [[created|%Y-%m-%d]])");

You can also use the backtick character instead of double quotes around a string to create a template string that does not require escaping returns, and is sometimes easier to read, like:

draft.processTemplate(`[body]]
(Created [[created|%Y-%m-%d]])`);

Perfect, thanks!

FYI, you left out one square bracket before the word “body” in the second example. Thanks so much!