Hi all
I just put together a 3-liner for creating a note and calling a template in one step rather than the 2-steps native to Obsidian. I thought i would share as it may be useful for some.
Most importantly, this does not require user functions (i.e. works on mobile as well) or any sort of 3rd party plugin/code editor to Templater.
In your template folder, create a note that will generate future notes for you (I called it ‘NewFile’).
Paste the below code:
<%*
const fileName = await tp.system.prompt("File name")
const templateName = await tp.system.suggester(["Template1", "Template2"], ["Template1", "Template2"])
tp.file.create_new(tp.file.find_tfile(templateName), fileName, tp.file.folder())
%>
Replace the sample table items “Template1” & “Template2” with the name of your templates in both tables on the second line of code above.
By calling this template with code (‘NewFile’), a free text box will appear to enter your note’s name (NOT title) and a drop-down will then appear to let you choose your template from the list you have entered (in the second row above). I personally use notes’ frontmatter with a field ‘ChildrenType’ to predefine which templates to pre-populate as i use that script for all my master notes…
For you to then create a note, either call the ‘NewFile’ file from the command palette (‘create a note from a template’) or create a button somewhere (with the Buttons plugin):
\```button
name Create Note
type append template
action NewFile
\```