{{title}} place holder in the template is not getting replaced by title
sunravi opened this issue · comments
What happened?
I used a YAML front matter File: [[{{title}}.pdf]]. If I use obsidian core plugin template, this gets correctly replaced with the note title. But the add notes in projects plugin, it is not replaced with title. Instead it gets .pdf without title.
What did you expect to happen?
I expect the same behavior as template core plugin.
How can we reproduce it (as minimally and precisely as possible)?
-
Create a template and add the following YAML front matter
PdfFIle: [[{{title}}.pdf]] -
Add this template to the project.
-
Add note in the project using this template
Anything else we need to know?
No
Plugin version
1.8
Obsidian version
1.1.9
OS
Windows
I can see the problem. The create note modal doesn't define the title
function:
obsidian-projects/src/modals/create-note-modal.ts
Lines 33 to 34 in cc975a9
Here's how it should look like:
obsidian-projects/src/lib/data-api.ts
Lines 67 to 69 in cc975a9
We should probably extract this into a shared function so that they stay in sync.
obsidian-projects/src/modals/create-note-modal.ts
Lines 33 to 34 in fa86d5e
{{date}} & {{time}} placeholders are used here for filenames, not for note contents, corresponding to the project config "Default name for new notes".
The actual problem is, the name that used to fill the {{title}} placeholder wasn't included in the data recored, so it's impossible to access the name using record.values["name"]
. The limitation of creating file is, we should prepare the contents and parse the placeholder before the file is add by the filesystem, causing the filename also unavailable.
To solve it, I extracted the filename from the record id, then filled it into the {{title}}.
obsidian-projects/src/lib/data-api.ts
Lines 211 to 214 in fa86d5e
obsidian-projects/src/lib/data-api.ts
Lines 73 to 75 in fa86d5e