Prompting twice when using templater plug-in
RobsterPunch opened this issue · 16 comments
First of all what a great plugin, thank you so much, it works great!
I Just have a problem when using it in conjunction with the templater plugin. When i create a new note in a folder via your plugin it prompts all prompts from the template that im using twice. Any idea why this happens/ how to fix?
<%*
if (tp.file.title === "Untitled") {
const folder = await tp.system.prompt("Enter Customer name");
const title = await tp.system.prompt("Enter title");
if (folder && title) {
await tp.file.move(Customer/${folder}/${title}
);
} else {
// Handle the case where either folder or title is not provided.
await tp.file.move(Meetings/${title}
);
}
}
%>
Thanks and much love
Rather surprising, to be honest.
What are your settings for templater (template per folder, …) and for the plugin ?
Using now folder template but template in my plugin, I don't repro the bug. Maybe the template is triggered twice because of a conflict.
I will try to communicate this the best way I can, hope this helps:
Your Plugin:
{
"folder": [
{
"path": "Meetings",
"commandName": "Meeting",
"template": {
"type": "none",
"format": "Meetings",
"position": "prepend",
"separator": "abc",
"increment": false
},
"fileName": "Untitled",
"opening": "current",
"focused": true,
"splitDefault": "horizontal",
"templater": "Allgemein/Templates/Meeting Template.md"
},
],
"customVariables": [],
"enableAllFolder": true,
"listAllFolderInModals": true
Templater:
{
"command_timeout": 5,
"templates_folder": "Allgemein/Templates",
"templates_pairs": [
[
"",
""
]
],
"trigger_on_file_creation": true,
"auto_jump_to_cursor": false,
"enable_system_commands": false,
"shell_path": "",
"user_scripts_folder": "Allgemein/Scripts",
"enable_folder_templates": false,
"folder_templates": [],
"syntax_highlighting": true,
"syntax_highlighting_mobile": false,
"enabled_templates_hotkeys": [],
"startup_templates": [
""
],
"enable_ribbon_icon": true
}
Anything else that could be helpful?
Pretty surprising. With the same settings, the template is not triggered twice and work as it should 🤔
Does it somehow make a difference that i trigger the new note via a hotkey?
No, I test using the command from palette so it doesn't make any difference.
Ok then I will have to test a bit further on my system, maybe somehow a different plugin causes it.
Sorry for stealing your time!
No worry! If you found something, tell me !
I just recorded the bug as well, just to show you.
also dectivated all other plugins in between (except templater) but still does not work. 😄
https://github.com/Lisandra-dev/obsidian-create-note-in-folder/assets/122817867/4e201d6c-8631-4d04-8d84-f97383f5ff87
Hmm, could you open the Dev console (CLTR + MAJ + I) to show if there are, by chance, any log ?
I really don't understand why templater is trigger twice, as I can't repro in my own side with the same template :<
I think my plugin is not in the cause here :/
The error seems to be given by the dictionnary plugin and calendar.
I deactivated both Plugins. Then the console shows nothing of interest. Seems like this will remain a mistery 😆
@Lisandra-dev, I also have Templater triggering twice.
In my case, this is because Create Note in Folder has a Templater template path set for a folder definition, and Templater itself has the "Trigger Templater on new file creation" option enabled, thus Templater triggers twice. For example, my template prompts me twice to enter the new notes file name.
If Create Note in Folder could have an option to simply insert the template rather than trigger it, then I assume both options could remain enabled (Templater would trigger what New Note in Folder inserts)? It depends on the order of which plugin acts first I guess.
The reason for keeping both options enabled is that I'd like to still be able to click the "Open today's daily note" button to trigger a Templater template, and this is only possible with its "Trigger Templater on new file creation" enabled I think. The Templater option also allows me to enable its Folder Templates option with /
as a fallback on the off chance something outside of Create Note in Folder creates a new note, or I insert a template using Templater itself I guess.
Hopefully I explained that simply enough!
I think it's too much complicated here… Templater don't have public API so I need to search each time for fix.
For me, the best option is to mimic create note in folder with a Templater command and scripts :/
If Create Note in Folder could have an option to simply insert the template rather than trigger it, then I assume both options could remain enabled (Templater would trigger what New Note in Folder inserts)? It depends on the order of which plugin acts first I guess.
Do you think this would work as a workaround @Lisandra-dev? A simple toggle to disable your plugin from triggering the Templater template -- only insert it (and let Templater trigger it by its "Trigger Templater on new file creation" option). Until there's a better solution, maybe a toggle like this is enough?
You can litteraly use templater for a folder so I don't know why do you want to use my plugin instead?
You can move and create file in a specific folder directly from template…
tp.file.create_new(text, name, false, folder);
in my case, for example. With name the name of the file, and folder the path.