Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompting twice when using templater plug-in #10

Open
RobsterPunch opened this issue Oct 16, 2023 · 16 comments
Open

Prompting twice when using templater plug-in #10

RobsterPunch opened this issue Oct 16, 2023 · 16 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@RobsterPunch
Copy link

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

@Mara-Li
Copy link
Owner

Mara-Li commented Oct 16, 2023

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.

@Mara-Li Mara-Li added the bug Something isn't working label Oct 16, 2023
@RobsterPunch
Copy link
Author

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?

@Mara-Li
Copy link
Owner

Mara-Li commented Oct 16, 2023

Pretty surprising. With the same settings, the template is not triggered twice and work as it should 🤔

@RobsterPunch
Copy link
Author

Does it somehow make a difference that i trigger the new note via a hotkey?

@Mara-Li
Copy link
Owner

Mara-Li commented Oct 16, 2023

No, I test using the command from palette so it doesn't make any difference.

@RobsterPunch
Copy link
Author

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!

@Mara-Li
Copy link
Owner

Mara-Li commented Oct 16, 2023

No worry! If you found something, tell me !

@RobsterPunch
Copy link
Author

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

@Mara-Li
Copy link
Owner

Mara-Li commented Oct 16, 2023

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 :<

@RobsterPunch
Copy link
Author

grafik

This is what appears when i insert a new note via hotkey.
When i just insert the template via rightclicking on the folder everything works fine..

@Mara-Li Mara-Li added the help wanted Extra attention is needed label Oct 16, 2023
@Mara-Li
Copy link
Owner

Mara-Li commented Oct 16, 2023

I think my plugin is not in the cause here :/
The error seems to be given by the dictionnary plugin and calendar.

@RobsterPunch
Copy link
Author

I deactivated both Plugins. Then the console shows nothing of interest. Seems like this will remain a mistery 😆

@redactedscribe
Copy link

@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!

@Mara-Li
Copy link
Owner

Mara-Li commented Nov 18, 2023

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 :/

@redactedscribe
Copy link

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?

@Mara-Li
Copy link
Owner

Mara-Li commented Dec 2, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants