The problem is, the “tp.frontmatter” function is looking for preexisting frontmatter in target file, not in the template file itself. If you want to reuse some data in the template, you better save it as variable.
Hi reaty, what do you mean by the target file? Both the template and the file created from the template have the same frontmatter variables defined, as I explained. Perhaps if you could explain how you think the ‘tp.frontmatter’ function can be used successfully, I might understand better.
The file, that you created from template, will have the same frontmatter only after the template code is executed. Templater tries to run tp.frontmatter function BEFORE it pastes the frontmatter into the file, that’s why it can’t find anything. You can only use tp.frontmatter if you create file first, write the frontmatter in it manually, and only then insert the template.
If you want to create the file from template and paste the same thing several times, you should use js variable instead. For example:
<%* let myVar = 10 %>
number: <%* tR += myVar %>
The number is <%* tR += myVar %>.