feat: add company_templates_folder setting#1713
Open
C-Bjorn wants to merge 7 commits intoSilentVoid13:masterfrom
Open
feat: add company_templates_folder setting#1713C-Bjorn wants to merge 7 commits intoSilentVoid13:masterfrom
C-Bjorn wants to merge 7 commits intoSilentVoid13:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new optional
company_templates_foldersetting that allows organisations (or any user running a shared/managed vault) to maintain a second template folder whose contents take priority over the personaltemplates_folder.When the setting is empty (default) Templater behaves exactly as before — fully opt-in, zero behaviour change for existing users.
What this adds
src/settings/Settings.tscompany_templates_folder: stringadded to theSettingsinterface andDEFAULT_SETTINGS(default"")add_company_template_folder_setting()UI method — single folder input withFolderSuggestautocomplete, displayed immediately below the existing "Template folder location" settingsrc/core/Templater.tsresolve_template_tfile(template_str: string): TFilecompany_templates_folderis set, extracts the basename of the requested template and looks for a matching file in the company folder first (handles bothName.mdand bareNamereferences)resolve_tfile()behaviour when the company folder is empty or no match is foundon_file_creation()updated to calltemplater.resolve_template_tfile()instead of bareresolve_tfile()for both folder template and file regex template resolution — ensures the company folder wins on name collision at runtimecompany_templates_folderis now automatically skipped inon_file_creation(), exactly astemplates_folderis. Files created inside the company templates folder will never trigger template processing (no need to also add the folder to the "Ignore folders on file creation" list)Behaviour
company_templates_folderis emptycompany_templates_foldertemplates_folderTesting
pnpm run build(334.7 kb)