Thanks, @Christian. Is it possible for TFile to refer to the current file?
My hope is to use Templater to update the metadata I add to a file (both YAML and dataview). Here’s an example.
Pretend I have a file:
---
tags: people
alias:
template: people
version: 2
---
# Metadata
Pronunciation::
Context:: [[Wyoming St]]
---
Then, pretend I update the template for these kinds of files to include a new field (e.g., Address::):
---
tags: people
alias:
template: people
version: 2
---
# Metadata
Pronunciation::
Context::
Address::
---
I want a template that I can “expand” that will populate with the current file’s metadata already filled in. I am able to access the values for the YAML front matter using Templater. Mind you, I’m not a programmer, so I have no idea if there’s a better way to do this, but the following works for updating the YAML front matter:
---
<%* if ((tp.frontmatter.tags) == null) { _%>
tags: people
<%* } else if (tp.frontmatter.tags.contains("people")) { _%>
tags: <% tp.frontmatter.tags %>
<%* } else { _%>
tags: people, <% tp.frontmatter.tags %>
<%* } _%>
<%* if ((tp.frontmatter.alias) == null) { _%>
alias:
<%* } else { _%>
alias: <% tp.frontmatter.alias %>
<%* } _%>
template: people
version: 2
---
I’m hoping to use MetaEdit to update the dataview values. I think that a Templater Javascript Execution Command can handle the rest of the “expansion,” using the MetaEdit API. I’m thinking that I’ll essentially add one line per dataview value, like you do in the New Task template on your GitHub page.
<%*
const {getPropertyValue} = this.app.plugins.plugins["metaedit"].api;
tR = `
Address:: ${await getPropertyValue("Address", "TFile")}
`
%>
I just don’t know how to make “TFile” or whatever I’m supposed to put between Address:: ${await getPropertyValue("Address", and )} refer to the current file.