I’m new to Obsidain (and love it) and installed a few plugins that I want to try out. Templater is one of them. In trying to practice with it and see what it does I copy the example code in bulk for one of it’s builtin functions and paste it into a newly created note located in the Templates folder which is configured to be where Templater looks for its templates. When I try to create a note from the template (alt+n or the equivalent from the command palette) I get the following error…
Templater Error: Invalid reference date format, try specifying one with the argument ‘reference_format’
I see there are a few issues about this on the author’s github but the content of those issues is not helpful for other users coming to the issue to find a solution to their problem.
So I go move the entire example code out of the note to paste back one line at a time (line by line) and create a note from that template with just one of the example lines at a time. All pass except 4 lines of code…
File's title date + 1 day (tomorrow): <% tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD") %>
File's title date - 1 day (yesterday): <% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>
File's title monday: <% tp.date.weekday("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD") %>
File's title next monday: <% tp.date.weekday("YYYY-MM-DD", 7, tp.file.title, "YYYY-MM-DD") %>
Each of the failing lines generates the error shown shown in this post above.
I’ve looked at the Templater documentation for tp.date.now(format: string = “YYYY-MM-DD”, offset?: number⎮string, reference?: string, reference_format?: string) as well as tp.file.title. I see that each of the failing lines of code contains something not found in the other lines of code that aren’t fail tp.file.title
but the cause of and the solution to my problem eludes me.
It isn’t clear from the documentation what is going on. What is the outcome and how the code works supposed to be from the execution of any one of those lines of failing code? What is missing that is causing it to fail? It isn’t clear whether the date is supposed to be inserted into the note title when using a template with that code or whether the code in the template is supposed to be getting the date format from the title of the note created by the template. In the latter case it doesn’t make sense since how do you get data from the title of a note that doesn’t exist yet? In the former case it doesn’t make sense why it wouldn’t just work the way it is written and the only thing I can ascertain is that maybe there is some other code that is missing from the example code that is needed for it to work correctly.
Can someone explain what is really going on here and what has to be done to make each of those failing lines of code work?