I’m trying to create a new file, and then immediately open it in a new tab & focus it via Templater’s create_new
method.
Using Dataview & Templater I’ve got it creating a file in the location I desire, and even have it so it opens said file after creation… But I just can’t get it to open the file in a new tab.
async function createNewNote(currentDirectory, targetTag, newFileMetadata) {
const newNoteName = await prompt(`please enter a name for the note`);
if ([null, ``].includes(newNoteName)) return;
const currentFolder = app.vault.getAbstractFileByPath(currentDirectory),
parentFolder = currentFolder?.parent,
dataFolder = parentFolder?.children?.find(
(child) => child?.name === `data`
),
additionalMetadata =
removeSpaces(newFileMetadata)?.replaceAll(`,`, `:\n`) + `:\n`,
content = `---\n` + `tags: ${targetTag}\n` + additionalMetadata + `---\n`;
// 'create_new' renamed via object deconstruction in the global scope
createNew(content, newNoteName, true, dataFolder);
}
That third parameter in the create_new
method is seemingly the only option for opening the file with Templater after creation, at least with said method. I’ve searched the forums, reddit, the internet in general for a solution but can’t find anything.
Happy to use any alternative methods to get this to open in a new tab after creation.