numeroflip / obsidian-auto-template-trigger

An obsidian.md plugin, to automatically trigger a template on new file creation
MIT License
33 stars 0 forks source link

Plugin prompts for template selection when using Templater folder templates #13

Open Pseudoscops opened 1 year ago

Pseudoscops commented 1 year ago

I really like this plugin and it has helped me to understand the basics of how Obsidian plugins work. I have never written or read any plugin before, so this is a great learning experience for me.

However, I have an issue with the plugin when I click on a link of tomorrow’s daily note that triggers Templater’s folder template and automatically applies a daily template. This plugin asks me what template I want to apply, which is redundant and annoying. I solved my problem by adding this code to shouldTriggerTemplatePrompt:

if (this.app.plugins.plugins["templater-obsidian"]) {
      let templater_folders = this.app.plugins.plugins["templater-obsidian"].settings["folder_templates"]

      for (let folder_info of templater_folders) {
        if (file.path.startsWith(folder_info["folder"]+"/")) {
          return false;
        }
      }
    }

I did not want to make a pull request without knowing if this is a feature that the author would like to have in the plugin, and without getting some feedback on the quality of the code. I am not sure if this is the best way to implement it, or if there is a more efficient way to do it (maybe by loading the list of Templater folder templates once when the plugin is initialized and then checking if the file path is in that list, or something like that). I would appreciate any comments or suggestions on how to improve it. Thank you for your time and attention.

Jetsadaporn87 commented 8 months ago

Can you tell me how? It must be added to which file? Thank you.

numeroflip commented 8 months ago

@Jetsadaporn87 Do you still experience this problem? If so, would you kindly provide details about what's the expected behavior in your case, and what's actually happening?