Hi there,
I need some help with the following templater code, but first I’ll describe shortly my use case:
I want to create “insight notes” out of my “source notes” and I want, that my “insight notes” inherit all the yaml of the “source note” it originates from (“source note” = “parent note” and “insight note” = “child note”).
The following templater code is heavily inspired by this thread and the solution of @holroy :
<%*
const dv = this.app.plugins.plugins["dataview"].api
const curr = tp.config.target_file
const dvCurr = dv.page( curr.path )
const baseFolder = app.vault.getAbstractFileByPath(dvCurr.file.folder)
const newFile = await tp.system.prompt("New file name")
const content =
`---
tags:
- note/insight
property1: ${ tp.frontmatter["property1"] }
property2: ${ tp.frontmatter["property2"] }
property3: ${ tp.frontmatter["property3"] }
parent_note: "[[${ dvCurr.file.name }]]"
---
`
/*
console.log("Content", content)
console.log(curr)
console.log( dv.page(curr.path) )
*/
await tp.file.create_new(content, newFile, true, baseFolder)
_%>
Pressing Strg + P => “open insert template modal” inside my source note out of which I want to create a new insight note works nearly perfectly fine, but:
If one of the inherited properties is of type list, e.g.:
property1:
- value1
- value2
in the new insight note, these values will be written in this wrong format:
property1: value1, value2
which will return an error inside Obsidian.
So my question is: How do I have to modify the templater script, to get propper yaml in my insight notes
Thanks in advance,
kind regards,
Silias