Add support for Templater templates in new notes#889
Add support for Templater templates in new notes#889H3mul wants to merge 2 commits intoobsmd-projects:mainfrom
Conversation
|
Thank you so much on contributing! I will review this and add A quick question, can it be a plugin-level config so that users can always call templater with one setup? To achieve this we need to ensure that templater would skip empty/plain templates and let Projects handle it. Also in the origin issue, bon proposed a template-level enable mark. It seems that the config level should be carefully designed. |
| const tagSet: Set<string> = new Set( | ||
| templateTags.concat(record.values["tags"]) | ||
| ); | ||
| record.values["tags"] = [...tagSet]; |
There was a problem hiding this comment.
Quick explaination on L117-L131.
There's a certain case that, when user create a new note under a tag-sourced project, the tag is expected to added to the frontmatter automatically. It's neccessary to uniquify the tags field if there's already one listed in the template. See more in #646
So in the useTemplater branch we hope it can act the same.
There was a problem hiding this comment.
Ah, I see. I assumed this was part of the legacy templating process and left it untouched
Out of curiousity, is there any reason not to move this handling to doUpdateRecord()? This tagging feature seems similar to assigning the correct frontmatter properties to notes after creation (eg, when creating the note from a board that's tracking a particular property value) which is already handled there.
If this seems ok to you I'll make this refactor - seems cleaner to me anyway: we render the a new note file with/without template and then we edit its frontmatter with correct properties and tags in doUpdateRecord().
|
Huh... during testing, I noticed Templater has a setting for automatically picking up new files and rendering templates transparently - technically this fulfills #42 as is :) it satisfies my use-case The only reason I see to go forward with the changes in this PR is if someone wants to use Templater but doesn't want it to run on all new files for some reason. I'll be happy to continue working on this code if you think its enough of a use-case. Feel free to close this and #42 otherwise |
|
Yes please follow up on this PR, I had to enable the option in templater but I would like to not have it enabled as I am processing files from outside (and Projects is the only reason I did so). |

PR for #42, since that issue hasn't had any activity
In addition to the proposal, the project setting disappears from the menu if Templater is disabled/not installed, as requested