Generating dynamic file names

Is it possible to use a capture template that can reference a variable once captured, so an author can be used for both the file name and text in the note?


;; /org/templates/
* Source:
Author: %^{author}
Title: ${title}

;; config.el

("b" "book" plain
(file "~/org/templates/")
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}-${author}.org" "#+title: ${title}\n")
:unarrowed t)

The following works on my end. You seem to be using Doom, so I can’t account for Doom’s peculiarity (if any; I don’t even know).

This method prompts for the author for the first time, and then pass it to the next one.

(cl-defmethod org-roam-node-author ((node org-roam-node))
  (let ((author (cdr (assoc-string "AUTHOR" (org-roam-node-properties node)))))
    (if author author
      (setq author (read-string "Author: "))
      (push (cons "AUTHOR" author) (org-roam-node-properties node))

Edit: Changed the code to use push instead of setf – the properties of the node (org-roam-node-properties) may not be nil if you are capturing to an existing node. I think we should use push to add to the list rather than set it anew.

I also changed the template org file – note author uses ${prop-name}, different from your original (not sure if the original way works – didn’t test).

* Source:
Author: ${author}
Title: ${title}

Basically, you can use your capture-template as is. Just add the method and change the org file.