Which templater functions require await

What I’m trying to do

Is there an easy way to tell if a templater function requires an ‘await’

I know with some functions you can kind-of guess, but I’ve guess wrong in a couple of places

I’m also interested in a similar question for dataview.

Things I have tried

I tried something like this:
tp.file.create_new = =tp.file.create_new.constructor.name === "AsyncFunction"

based on JavaScript Detect Async Function

but it doesn’t appear to work as it doesn’t recognize “constructor”

I did have single backticks around the =tp.file...

The short answer is most functions related to file and input/output operations where you don’t really now how long it’ll take to do the operation.

In most cases, you’ll either know it by experience, or you’ll look it up in the documentation of the various modules/plugins. For Templater it’s not marked directly, but the examples usually give the correct indication on whether you need it or not. For DataviewJS the asynchrous functions (aka those needing await should be marked with an hourglass in the documentation.

1 Like

If you want to showcase either markdown, or code blocks, or dataview queries properly in a forum post, be sure to add one line before and one life after what you want to present with four backticks, ````. This will ensure that any other backticks (like for code blocks) is properly shown.

For the even worse case of inline code with backticks, like `= tp.file(…)`, you’ll need to write stuff like:

<code>\`= tp.file(...)\`</code>


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.