mo-seph / obsidian-note-from-template

Simple plugin to create Notes from a template, and fill in fields defined there
MIT License
108 stars 9 forks source link

Set new filename based on date, default to current date #38

Closed jancbeck closed 2 years ago

jancbeck commented 2 years ago

Great job on the plugin! Here's what I'd like to accomplish:

  1. Create a new file called "Meeting {{date}}" where that variable is automatically set to today's YYYY-MM-DD without me providing it
  2. However, I'd like to have the option to provide a custom date. If not provided, default to today.
  3. Inside the newly created note, replace {{date}} with either provided date or today. Excuse me if I overlooked anything in the documentation but I played around with it for a while and could not get it to work.
FelipeRearden commented 2 years ago

Trying to help here .... :)

Try something like this ....

---
template-output: "<Folder_name>"
template-filename: "Meeting {{Date:currentDate:yyyy-MM-dd}}"
---

The syntax for {{date}} is {{Variable_Name:currentDate:date_syntax}}

I did not use on Filenames, but I 🤞 it will work for you !


When you open the modal you will see that theDate field will be filled with2022-04-21 but you can edit when you need.


Have a great day !!

jancbeck commented 2 years ago

Thanks for your quick reply! Putting the frontmatter values in quotes did the trick (as correctly stated in the documentation 😓). I'm so happy I don't have to mess with Templater to get something simple like this going. 😌

Any idea how I can get the empty frontmatter removed from the note?