Alternate location for Templates for Folder Templates #1264
djdanner
started this conversation in
Ideas & Feature Requests
Replies: 1 comment 13 replies
-
Templater is so extensible, you can do this today! Here's a Templater script you can use to accomplish this. Set this as your only folder template at the root folder ( <%*
// Search for "Template.md" note recursively, starting at the current folder and ending at the root folder
let folder;
let folderTemplate;
do {
if (!folder) {
folder = app.vault.getAbstractFileByPath(tp.file.folder(true));
} else {
folder = folder.parent;
}
folderTemplate = folder.children.find(x => x.name === "Template.md");
} while (!folderTemplate && folder.path !== "/")
// Apply folder template (if applicable)
if (folderTemplate) {
tR += await tp.file.include(folderTemplate);
}
-%> |
Beta Was this translation helpful? Give feedback.
13 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For Folder Templates, instead of specifying the location of a Folder's Template in a Templater Setting, could a Note named "Template.md" simply be placed in the Folder? Then any Note created in that Folder, or any of its Subfolders, would use the Template in that Folder.
If there were multiple Template.md files in a Folder Hierarchy, you would stop looking as soon as you found a Template when going-up the Parent Chain.
This could be done as an alternative to the existing method so that both methods are supported.
Beta Was this translation helpful? Give feedback.
All reactions