What I’m trying to do
I want to create a template which I use for notes in a project. In this template I want to insert tags which are in the previously opened note. Meaning if the “master note” of the project has the tag “group” the same tag is inserted in the new note. With the script below I am able to do this if the tags are in the frontmatter (between the two “—” lines, but not if the tags are later in the document as “group::”
Things I have tried
This template works if the tags are in the frontmatter:
<%*
let title = tp.file.title
if (title.startsWith(“Untitled”)) {
title = await tp.system.prompt(“Title”);
todaysDate = tp.date.now(“YYYY-MM-DD HH:mm”);
}
let files = this.app.workspace.getLastOpenFiles();
let lastFile = this.app.vault.getAbstractFileByPath(files[0]); // t file
// Collects frontmatter of other note
var get_frontmatter = this.app.metadataCache.getFileCache(
tp.file.find_tfile(lastFile.basename)
)?.frontmatter || {};
get_frontmatter.group
%>—
title: <%* tR += title %>
project: <%* tR+= lastFile.basename %>
created: <% todaysDate %>
noteType: note
group: <% get_frontmatter.group %><%* tR += title %>
<%* tR+=
Parent note: [[
+ lastFile.basename +]]
%><% tp.file.cursor(1) %>
How can I create something which inserts tags in the “master note”, where the tags are not in the frontmatter, but inserted within the note as for instance “group:: group1”?