Meta
up:: ๐งช Code Diary
type:: #log/code
language:: Plugin - Templater
program:: Obsidian
topics:: Coding
Using Includes in Templater
Language:: Plugin - Templater
Program:: Obsidian
Summary
Using Templaters include function
Code
tp.file.include()
doesnt require a path. Just the internal link with the title is ok. For example, if the template that you want to get the content of and added to current file has the name "fragment-Projects", just do awaittp.file.include("[[fragment-Projects]]")
. See doc.If you want to display the content of
"[[fragment-Projects]]"
, you can do that either:in a
<% %>
tag, i.e.,<% await tp.file.include("[[fragment-Projects]]") %>
.
Or you can just addtR+= await tp.file.include("[[fragment-Projects]]")
to your above script.if (!(await this.app.vault.adapter.exists(workdir))) { await this.app.vault.createFolder(workdir); } await tp.file.move(workdir + title); tR+= await tp.file.include(`[[fragment-${type}]]`);
Explanation
Result
up:: ๐งช Code Diary