Hi I’m trying to make a template with templater for new notes. I want the template to:
Ask me for the name of the note.
set some frontmatter keys.
But I’m having some problem.
I create the templater folder and inside a script folder. I create a notaNueva.md template and a nuevaNota.js
I call the script from the templater.
I allready resolve the name part. But I can resolve the frontmatter problem.
Also the call for the funcion is still there after the new note is create.
nuevaNota.md
<% tp.user.nuevaNota(tp) %>
nuevaNota.js
async function nuevaNota(tp) {
let title = await tp.system.prompt("Ingresar el nombre de la nota");
await tp.file.rename(title);
await tp.frontmatter.title[title]
}
module.exports = nuevaNota
The result of this is a new note with the name I want but with the js call as test.
Yes, I read something. But everything I read about “asking for the name of the note” refers to templater. In addition to setting the keys with Quickadd, can I make a function that asks me for the name of the note?
Here’s my simple Templater template for a General Note. Prompts for Note title if the current note is “Untitled” (i.e created from new file, not existing, already named title.
---
created: "<% tp.file.creation_date("YYYY-MM-DD") %>"
year: <% tp.file.creation_date("YYYY") %>
topic: <% tp.file.cursor(1) %>
tags:
-
aliases: []
---
<%*
//If File is untitled prompt the User to set a Title (Source: https://github.com/SilentVoid13/Templater/discussions/259)
let title = tp.file.title
if (title.startsWith("Untitled")) {
title = await tp.system.prompt("Title") ?? "Untitled";
await tp.file.rename(`${title}`);
} %>
Last Modified: `=dateformat(this.file.mtime, "DDDD, HH:mm")`
# <% tp.file.title %>
<% tp.file.cursor(2) %>