Templater Plugin: `tp.file.include()` Only Inserts Empty Lines

Hello everyone,

I’m encountering an issue with the Templater plugin in Obsidian and am hoping to find some support here. My goal is to insert the content of specific files (named A, B, and C) based on user selection into a template. To achieve this, I’m using the tp.file.include() function as follows:

javascriptCopy code

<%*
const options = ["A", "B", "C"];
const choice = await tp.system.suggester(options, options, false);

if (choice === "A") {
    await tp.file.include("[[A]]");
} else if (choice === "B") {
    await tp.file.include("[[B]]");
} else if (choice === "C") {
    await tp.file.include("[[C]]");
}
%>

The issue is that instead of inserting the expected content of the files, only an empty line gets inserted into the document. I’ve already made sure to:

  • Check that the file names are correct and exist in my vault.
  • Ensure the files have content and are not empty.
  • Use the latest version of Templater and my Obsidian is up to date.
  • Deactivated all other Plugins.

I also tried specifying the file paths and names in different ways, but to no avail. I’ve reviewed the documentation, and my approach seems to align with the guidelines.

Has anyone experienced something similar or has an idea what might be causing the issue? Any hints or suggestions would be greatly appreciated!

Thank you in advance for your help!

I found a solution:

<%*
const options = ["A", "B", "C"];
const fileNames = { "A": "A", "B": "B", "C": "C" }; 
const choice = await tp.system.suggester(options, options, false); 

if (choice) {
  const fileName = fileNames[choice];
  tR += await tp.file.include(`[[${fileName}]]`);
}
%>