Templater code is replaced with empty line

My template immediately starts with a code block that prompts for user input then moves the new file. Under that is frontmatter that includes a variable created in the previous code block.

When i create a new file with this template, the frontmatter is preceded by a single line break, when i expect it to start with “—”. It’s as if the first code block is replaced with a linebreak for some reason.

Does anyone know why this occurs, and how i can work around it?

Below is my template:

<%*
let dateOfSession = await tp.system.prompt("Date of Session:", tp.file.creation_date("DD/MM/YYYY"))
await tp.file.move("/Meetings/Therapy/"  + dateOfSession + " - Therapy")
%>
<%"---"%>
Date: <% dateOfSession %>
Last Session: 
Paid: false
<%"---"%>

And here is the result:


---
Date: 28/12/2023
Last Session: 
Paid: false
---

You can add - after the first <% and Before the last, like this :

<%-*
let dateOfSession = await tp.system.prompt("Date of Session:", tp.file.creation_date("DD/MM/YYYY"))
await tp.file.move("/Meetings/Therapy/"  + dateOfSession + " - Therapy")
-%>
<%"---"%>
Date: <% dateOfSession %>
Last Session: 
Paid: false
<%"---"%>
2 Likes

Thank you!

One of those dashes should suffice, btw.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.