Hi there,
my templater scripts has two parts (thanks to the explanations of @gino_m in that thread):
- adding / updating properties
- Moving note to specific folder
- adding a dataview
If I use this templater script I see the following:
- No error message
- the dataview source code
- After (assumable) 0,5 seconds the dataview code gets deleted and the properties are added
My question is:
Why will the dataview be deleted?
… what is funny:
If I use this script a second time, on that note, that - now - already has the right properties, the dataview will be added…
Templater script for library notes
<%*
// Check if the 'value' tag exists before adding it
setTimeout(() => {
app.fileManager.processFrontMatter(tp.config.target_file, frontmatter => {
let key = "aliases"
let value = ""
if (!frontmatter[key] || !frontmatter[key].includes(value)) {
const prop_Array = Array.isArray(frontmatter[key]) ? frontmatter[key] : [];
if (!prop_Array.includes(value)) {
prop_Array.push(value);
frontmatter[key] = prop_Array;
}
}
key = "created"
value = tp.date.now()
if (!frontmatter[key] || !frontmatter[key].includes(value)) {
const prop_Array = Array.isArray(frontmatter[key]) ? frontmatter[key] : [];
if (!prop_Array.includes(value)) {
prop_Array.push(value);
frontmatter[key] = prop_Array;
}
}
key = "tags"
value = "note/library"
if (!frontmatter[key] || !frontmatter[key].includes(value)) {
const prop_Array = Array.isArray(frontmatter[key]) ? frontmatter[key] : [];
if (!prop_Array.includes(value)) {
prop_Array.push(value);
frontmatter[key] = prop_Array;
}
}
delete frontmatter['Unwanted property']
});
}, 550); // Timeout to allow preceding clipboard operations to complete
_%>
<% await tp.file.move("Atlas/Maps/Library/" + tp.file.title) %>
```dataview
Table tags, file.folder
From #note or "Atlas"
Where contains(Library, [[]])
```
Thanks in advance,
kind regards,
Silias