Closed alexjbarnes closed 9 months ago
You're setting the file name to an empty string, what are you expecting the file name to be when the file is created?
fileName: ""
Yes sorry I should of mentioned that, I leave file name blank, then inside the journal_template there is a templater block that renames it to todays date. I've copied that in below. I'm not sure that's the issue, as it creates the new note with today's date fine, just at the wrong level in the directorys.
<% tp.file.rename( tp.date.now("DD-MM-YYYY") ) %>
What should the file name be before your template renames it? That's where I'm a bit lost, I need to know what it was doing before.
I don't currently set it, as it is immediately renamed. So I'm guessing it is either empty string or defaults to untitled.
Yes I just tried it without the rename command in the template and it just gets set to untitled. I have just tested it with setting a default name for the note instead of an empty name and it works fine in latest version. So guessing it's just a weird edge case of having no file name messes up the path creation. Happy to close this issue if you want, and I'll just add file names into my buttons. Thanks for your help.
I was able to encounter the same issue using just Templater and tp.file.create_new()
. Here's the equivalent I tested with.
<%*
const templateFile = tp.file.find_tfile("Templates/journal_template.md");
const folder = app.vault.getAbstractFileByPath("Work/Organiser/DB/Journal");
const fileName = "";
await tp.file.create_new(templateFile, fileName, true, folder);
-%>
I have fixed this in 2.2.3, I believe this will also resolve the issue you were facing with metabind!
Brilliant thank you 👍
Plugin information (please complete the following information):
Describe the bug When using versions greater 2.1.4, when using templater to create a new note from within metabind it creates the note in the parent folder rather than the specified folder. For the example below, notes are created in the journal folder in version 2.1.4 and in the DB folder in versions 2.2.0 and above. I have tried adding an extra / to the end of path but get error folder not found. Apologies if this is an issue with how metabind integrates with templater, i could just see changes in getting paths within templater recent releases. And downgrading to 2.1.4 fixes the issue.
Expected behavior Notes to be created within the specified directory.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.