Templater inserts blank lines

I am not sure if this belongs to here, maybe somebody can confirm this or explain this behaviour?

section of my template

# <% moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %>
[[<% moment(tp.file.title, 'YYYY-MM-DD').subtract(1, 'd').format('YYYY-MM-DD') %>]] | [[<% moment(tp.file.title, 'YYYY-MM-DD').add(1, 'd').format('YYYY-MM-DD') %>]]
<%* const dateToEvaluate = tp.file.title; %>
<%* const dayOfWeek = moment(dateToEvaluate, 'YYYY-MM-DD').weekday(); console.log("m", dayOfWeek) -%>

after file creation from template

# Sunday, December 17, 2023
[[2023-12-16]] | [[2023-12-18]]
                        <-- empty line
## Tasks

If the title 2 tasks is also in the template, I think you should avoid leaving a line with templater code that does not write anything, and therefore put the last line at the end of the line above And otherwise, be careful to never put a newline or empty line at the end of your template, otherwise it will insert them too

Templater has white space control you could try (the second section):

My God! I just realized, that I was unknowingly using the whitespace control, but not to my favor, haha. Sorry, somehow I didn’t make it to the synonym “whitespace”, that post made everything clear. Thank you!

Yeah, the title 2 was coming directly after it. Adding the commands to the line above worked, but actually I just had to use whitespace control and put an underscore to the brackets of those non-inserting lines:
<% (…) _%>
<% (…) _%>

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