Templater icon indicating copy to clipboard operation
Templater copied to clipboard

Docs don't show which functions return a Promise and need `await`

Open huyz opened this issue 1 year ago • 3 comments

Plugin information (please complete the following information):

  • Templater version: 1.12.0

Describe the bug

The API docs don't specify which functions are async (i.e., return a Promise), and thus require the use of await.

Expected behavior

All API functions should have a **Returns** section which is clear whether a Promise is returned or the expected content.

Example: https://silentvoid13.github.io/Templater/internal-functions/internal-modules/file-module.html#tpfileincludeinclude_link-string--tfile

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

Examples of confusion:

  • https://github.com/SilentVoid13/Templater/issues/445#issuecomment-1059815715
  • https://github.com/SilentVoid13/Templater/discussions/320#discussioncomment-3292361

huyz avatar Aug 13 '22 09:08 huyz

Would you mind adding it to the docs? They could use some love.

AB1908 avatar Aug 13 '22 09:08 AB1908

Interestingly, tp.file.exists, which calls app.vault.exists, just switched from sync to async in Obsidian v0.16.3

huyz avatar Sep 21 '22 08:09 huyz

Yeahhhhh it was using a sync method that didn't account for folders, so I changed it.

I tested it without an await and was getting results so thought I dodged a breaking change bullet, but it was a pretty basic test.

shabegom avatar Sep 21 '22 12:09 shabegom