Read capture template from file

Hello,
I’m trying to do something that I expected to be pretty trivial but no…

I want to read the roam template from a file like I do for org below.

  (setq org-roam-capture-templates
        (quote
         (
          ("d" "default" plain "%?"
           :if-new (file+head "${slug}.org" (file "~/org/templates/roam-default.template"))
           :immediate-finish t
           :unnarrowed t)
          )
         )
        )

  (setq org-capture-templates
        (quote
         (("p" "Private templates")
          ("pt" "TODO entry" entry
           (file+headline "~/org/private.org" "Capture")
           (file "~/org/templates/todo.txt"))))
  )

The code documentation is no help to me either.

template     The template for creating the capture item.
             If it is an empty string or nil, a default template based on
             the entry type will be used (see the \"type\" section above).
             Instead of a string, this may also be one of:

                 (file \"/path/to/template-file\")
                 (function function-returning-the-template)

             in order to get a template from a file, or dynamically
             from a function.

The template contains a compulsory :if-new property. This determines the
location of the new node. The :if-new property contains a list, supporting
the following options:

   (file \"path/to/file\")
       The file will be created, and prescribed an ID.

You just need to fix the structure of your list.

First let’s check the structure of org-capture-templates:

(setq org-capture-templates
        '(("pt"                                        ;; <= KEYS
           "Private templates"                         ;; <= DESCRIPTION
            entry                                      ;; <= TYPE
           (file+headline "org-private.org" "Capture") ;; <= TARGET
           (file "~/org/templates/todo.txt")           ;; <= TEMPLATE
           ...                                         ;; &rest plist
           ...))         

Now let’s inspect org-roam-capture-templates:

(setq org-roam-capture-templates
        '(("pt"                                        ;; <= KEYS
           "Private templates"                         ;; <= DESCRIPTION
            entry                                      ;; <= TYPE
           ;; <= TARGET is not on the list, sort of hidden;
           ;; in fact, it's in the plist
           (file "~/org/templates/todo.txt")           ;; <= TEMPLATE
           :if-new (file+headline "org-private.org" "Capture") ;; &rest plist
           ...))

So all what you need is to replace "%?" with (file “~/org/templates/todo.txt”)`.

Thanks mate - that helped a lot.

Below works for me in spacemacs.

  (setq org-roam-capture-templates
        '(("d" ;; key
           "default" ;; description
           plain ;; type
           (file "~/org/templates/roam-default.template") ;; template
           :if-new (file "${slug}.org") ;; target
           :immediate-finish t
           :unnarrowed t)
          )
         )

  (setq org-capture-templates
        '(("p" "Private templates") ;; main menu
          ("pt" ;; keys
           "TODO entry"
           entry
           (file+headline "~/org/private.org" "Capture")
           (file "~/org/templates/todo.txt")
           )
          )

You are welcome.