Obsidian broken templater code

Is obsidian also acting weird with you guys?
My template, which contains some templater syntax, doesn’t work anymore suddenly.
It always worked and without touching any settings it’s broken.
Please help me because my whole obsidian is acting weird because of this.

No one can help unless you paste the template in here (in a code block). A screenshot isn’t going to cut it. It looks like there’s some Dataview in there as well.

What have you tried? What are the steps you are taking? What’s the expected result? What actually happened?

I tried a lot of different formats but this is the one that worked previously.
The code block is under the screenshot below.
For the templater code here under, the expected result is to have a sort of navigation to the daily note of the day before and the other line, to the note of the day after.
The crazy thing is that it worked and suddenly yesterday without touching anything, it stopped working.
The expected result is this:

[[<%tp.date.now("YYYY/MM/DD", -1, tp.file.title,"YYYY/MM/DD")%>]] | [[<%tp.date.now("YYYY/MM/DD", 1, tp.file.title,"YYYY/MM/DD")%>]] 

Also my dataview doesn’t work but this is probably because it uses some templater syntax in it.
Here is the excpeted result to get a list of al the documents that are created on the day (and year ofcourse) of the daily note.

List FROM "" WHERE file.cday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.ctime asc

Hi J_B, in your first screenshot you seem to be looking at the template itself in reading mode, right? What happens, when you create a daily note from this template, that isn’t working any longer?

Note that looking in reading mode at a template with dataview relying on concrete data may result in parsing errors, for templater will do the magic only when a note is created from it.

1 Like

Thanks for reporting back. Now we’re getting somewhere.

In addition to what Mephi said, how are you triggering the template? In note titled 2024-07-12, using Templater: Open Insert Template modal, I’m applying a template of:

---
tags:
---

[[<%tp.date.now("YYYY/MM/DD", -1, tp.file.title,"YYYY/MM/DD")%>]] | [[<%tp.date.now("YYYY/MM/DD", 1, tp.file.title,"YYYY/MM/DD")%>]]

```dataview
List 
FROM "" 
WHERE file.cday = date("<%tp.date.now("YYYY-MM-DD")%>") 
SORT file.ctime asc
```

and this is the result:

CleanShot 2024-07-12 at 05.05.37

1 Like

It works!
Thank you!!
Is there a way that I don’t have to press Alt + e and selecting the template every time? because when I use the setting of the core plugin daily notes, I always have to delete everything and then press Alt + e.

And your solution for dataview works for 90% because it lists all the notes created TODAY. even when I try to use it on an older daily note.
Maybe someone knows the solution?

Hi again, from my understanding the dataview in template provided by ariehen works for today’s daily note when it is created today.
If you want to create your daily notes sometimes beforehand or afterwards e.g. via Calendar plugin, maybe instead you could try:

List FROM "" WHERE file.cday = date("{{date:YYYY-MM-DD}}") SORT file.ctime asc

Works fine for my own workflow.

If I’m understanding correctly, you are triggering the core Templates plugin and not Templater. If that’s the case, you can:

  • Disable core Templates if you aren’t using them.
  • Disable or change the hotkey for core Templates so it’s not triggered.

With Templater you also have the option of template hotkeys so you don’t need to choose the template after entering the hotkey.


As for the Dataview query, I just pasted what you had above. It can be written differently, but if it’s applied to the correct note daily note(s), it should be fine.