What I’m trying to do
I use the Daily Notes plugin and template to create both work and personal notes using
to create work and personal notes at the same time.
Some template code examples
<% for
…
const workFolder = “050. Work/My note/daily”;
const workTemplate = “900. Template/Period Note/Work Daily Template”;
const dailyTemplatePath = “900. Template/Period Note/Daily Template”;
const workTemplateFile = tp.file.find_tfile(workTemplate);
const dailyTemplateFile = tp.file.find_tfile(dailyTemplatePath);
let content = “”;
if (dailyTemplateFile) { { {
content = await app.vault.read(dailyTemplateFile);
tR += content;
const createdFile = await tp.file.create_new(workTemplateFile, workFile, false, workFolder);
tR += `\n[[${createdFile.basename}|link work note]]`
%>
I’ve created two templates as shown above, and I’m reading a file based on the path and creating a file based on the path.
-
part using templater
const workFolder = “050. Work/My note/daily”; -
filter tasks in the file 900. Template/Period Note/Work Daily Template
not done
due today
sort by priority
path does not include {{query.file.path}}
filter by function task.file.folder.includes(“050. Work/My note/daily”)
I realized that if I change the path once, I have to change everything in tasks.
I thought about applying it only to the notes I create in the future, but maybe I could set it as a global variable and use the path specified in the
I was wondering if it would be possible to flexibly use the specified path within the plugin.
Things I have tried
To solve this, I tried creating a js file within the templater path.
function workFolder () {
return 050. Work/My note/daily
;
}
module.exports = workFolder;
Then I created a test template file and ran it, and it returned
<% tp.user.work_folder() %>
and it was executed like below.
- Work/My note/daily
However, when I wrote the tasks query like below, it returned the following result
filter by function task.file.folder.includes(tp.user.work_folder)
I get an error.
Is there any way to specify and use global variables in obsidan?