Ability to add Lua expressions to suggestedName on templates?

I have a weekly journal note with a particular format and in v1 I could use the {{startOfWeek()}} syntax to insert an ISO format date (i.e. Journal: Week of {{startOfWeek()}})

I’ve tried to replace this with Lua (and I have a new space Lua function for startOfWeek) like so: Journal: Week of ${startOfWeek()} but sadly it does not render

Is there a way to support this functionality in v2 with Lua?

1 Like

Hey!

I have had a similiar issue which I solved by simply not confirming the name.

---
command: "☀️ Create: Todays Note"
key: "Alt-Shift-n"
suggestedName: "daily-notes/${os.date('%Y-%m-%d-%A')}"
confirmName: false
openIfExists: true

tags: meta/template/page
priority: 10
---

Or you can create a lua function to have a custom input and then you can concatenate that after the the path.

---
command: "📨 Create: New Note"
suggestedName: "notes/${promptPageName('Quick note name')}"
confirmName: false
openIfExists: true
tags: meta/template/page
priority: 100
---

and the lua function looks like this:

function promptPageName(text)
  local name = editor.prompt(text)
  if name == "" then
    return os.date("%Y-%m-%d")
  end
  return name
end

for your issue the suggestedName could be the following:
Journal/📔 Week of ${startOfWeek()}-${promptPageName("Additional data")}

Hope this helps,
Márton

I tried out with setting confirmName in the daily note and still works with the date, so maybe there is just some syntax issue

@Mrton0121 I just realized that at some point Silverbullet changed its template front matter syntax and I’ve been using an old version where I was still doing hooks. I need to reconfigure some of these and then see if that solves it! Thanks for the pointer!