Templater - parsing error

Hello everyone, I’m new to Obsidian and I’m trying to set up my vault to help me manage my projects in my work. I wanted to use the “templater” plugin but I systematically encounter errors and most often this error:

Here my code :


test_prop: “Propriete du frontmatter”

<%*
let testVar = “Bonjour”;
e.g. tp.file.echo(testVar + " du script !");
e.g. tp.file.echo("Propriete du frontmatter : " + tp.file.frontmatter.test_prop);
%>

The date is : <% tp.date.now(“DD-MM-YYYY”) %>

Thank you !

take out all the e.g. I think that’s breaking it.

Thank you for the reply !

I tried this but again an error :confused:

Afaik, tp.file.echo() isn’t a thing in Templater :innocent:

At least, it’s not listed in its File Module.

oh yeah. You’ll want to use this instead:
tR += testVar + " du script !"

When you’re inside the js execution templater commands (ie, within <%* %> you need to use tR to add page content.
If you just want to see if it’s working in a console printout, you need to use console.log() instead.

Here’s the relevant templater docs page:

Oh thank you for the links. In fact i just want to make template and put a date for the start of the project and after, Depending on the projects I need to complete and the deadlines I have to meet, I can set dates 3 days ahead, 5 days ahead, or 30 days ahead of the start date. Here’s what an AI suggests after numerous unsuccessful attempts:
“Today’s date: <% tp.date.now(“YYYY-MM-DD”) %>
Date +3 days: <% tp.date.now(“YYYY-MM-DD”, “3d”) %>”

With this code, I have today’s date on both lines, whereas on the second line, I should have the date +3 days, right?

This should work for the + 3 days :

<% tp.date.now("YYYY-MM-DD", "3") %>

This is just a slightly modified example from Templater’s documentation on tp.date.now() :blush:


it’s not works :frowning:
Do you think my app is broken or template?

It’s on me :sweat_smile: … There are unnecessary quotes in there, sorry :sweat_smile: :
(I’m multitasking too much :upside_down_face: )

Here’s the correct one:

<% tp.date.now("YYYY-MM-DD", 3) %>

Oh perfect it’s work thank you !!!

And now i have a différent problem. I would like to be able to indicate a start date in my header and then in the body of the page the tasks are updated with a due date based on the start date. Here is a code that was suggested to me but in return I have “invalid date”. Do you know why?

I know for sure you don’t need the 1st line (const moment = window....) :blush: .
(That’s all I can say at the moment :sweat_smile: )

1 Like

probably something wrong with your frontmatter.
Do you have “debut” in your frontmatter? Does it have a date?

there the full code source :

do you know where is the problem of the source ?

I finally found my mistake!!
Actually, I was using the keyboard shortcut “ALT+E” instead of manually selecting the template from “CTRL+P”… Yet the shortcut to insert a template was clearly displayed as “ALT+E”… But hey… the most important thing is that it works! :slight_smile: