#type/zk/zettel #a/maturity/seed
# [[Templater and Dataview]]
[[Templater]] can run javascript with this syntax: `<%* ... %>`. From this javascript, we actually have access to [[Dataview]], as well as the [[Obsidian]] runtime.
Using this syntax, I created a template to produce a table references that link to an author:
```javascript
<%*
const dv = app.plugins.plugins["dataview"].api;
const filename = tp.file.title;
const query = `TABLE
Title, Description
FROM [[${filename}]] AND #type/ref`;
const queryOutput = await dv.queryMarkdown(query);
tR += queryOutput.value;
tR += "<sup>*This table was generated with the 'References' template</sup>";
%>
```
Here, `tR` is a variable that can be appended to in order to add content for the template engine to render to your note.
It is also possible to use [[Templater]] to not even generate content at all, but just to run a script on your vault. [[Using Dataview on Obsidian Publish · joschua.io (web)|This article]] shows that with this epic snippet:
```javascript
<%*
const dv = app.plugins.plugins["dataview"].api;
const filename = "Recently Edited";
const query = `TABLE WITHOUT ID
file.link AS Note, dateformat(file.mtime, "ff") AS Modified
FROM ""
WHERE publish SORT file.mtime desc
LIMIT 7`;
const tFile = tp.file.find_tfile(filename);
const queryOutput = await dv.queryMarkdown(query);
// write query output to file
await app.vault.modify(tFile, queryOutput.value);
%>
```
---
Sowed on:: [[2024-10-24|2024-10-24]]
Sources:: [[Using Dataview on Obsidian Publish · joschua.io (web)]]
See also::
Related references::
Additional keywords::
Further reading::