How to use a specific property in template in dataview code block? #1417
-
I had a template file as below, I would like to have a dataview code block to query the note based on the third tag which is selected when the template is applied. I am not sure whether the question should be here or in Dataview repo, since it is a dataview template question. Question is: How to put the third tag in dataview block?
The template is planning to generate a note like below, when the template is applied and smallCarton is selected.
Will anybody give any hints or help on how to handle it? TIA Best Regards |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Also tried in template:
and get no results, and when switch to source mode, it says:
It keeps with |
Beta Was this translation helpful? Give feedback.
-
The tags for the file won't be available for Templater to retrieve from the metadata cache until after the file is created, which is too late for your template code. I would recommend storing the data in a variable and referencing it in multiple places in your template, something like this. <%*
const inputTags = await tp.system.suggester(["1 tag3", "2 tag4", "3 tag5"], ["smallCarton", "bigCarton", "smallPlasticBox", "bigPlasticBox"], false,"input tags");
-%>
---
tags:
- tag1
- tag2
- #<% inputTags %>
createdDate: <% tp.date.now() %>
---
## Dataview Query
```dataview
table createdDate
from #<% inputTags %>
``` |
Beta Was this translation helpful? Give feedback.
The tags for the file won't be available for Templater to retrieve from the metadata cache until after the file is created, which is too late for your template code.
I would recommend storing the data in a variable and referencing it in multiple places in your template, something like this.