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

Bug: When enabled, Templater Folder Templates stop working #40

Closed
chrisgrieser opened this issue Jan 23, 2022 · 20 comments
Closed

Bug: When enabled, Templater Folder Templates stop working #40

chrisgrieser opened this issue Jan 23, 2022 · 20 comments

Comments

@chrisgrieser
Copy link

I think this is due to the plugin inserting text into the file before Templater's "on the creation of an empty file" condition is checked.

Screenshot 2022-01-23 13 38 42

@dvcrn
Copy link
Owner

dvcrn commented Jan 29, 2022

Are you able to get around this when you ignore the Templater/ folder in this plugins settings?

@chrisgrieser
Copy link
Author

You mean the folder where I store my templater templates? That folder I do already ignore

@brandonkboswell
Copy link

I am also running into this.

@Gman0909
Copy link

Gman0909 commented Feb 9, 2022

Same issue here

@JohnPaton
Copy link

Same!

@dvcrn
Copy link
Owner

dvcrn commented Feb 12, 2022

Since I don't use templater it would be helpful if anyone had ideas what to try to resolve this instead of just commenting same 😇

@brandonkboswell
Copy link

The issue appears to be that this plugin adds content prior to templater's hook to add the default template for a given folder. Perhaps adding an option to have Obsidian Filename Heading Sync only add titles to pages with content would make them compatible with each other?

@dvcrn
Copy link
Owner

dvcrn commented Feb 13, 2022

How about adding a option to disable the "file open" event hook? So it only modified on save

Another idea, though hacky, would be to add artificial delay after a file has been opened

I'm guessing there is no way to identify a templater file since it's empty first? If we can then we could just add a ignore rule

@chrisgrieser
Copy link
Author

How about adding a option to disable the "file open" event hook? So it only modified on save

that would work, if you restricted it to the opened file – applying the sync to the file you are leaving to open another is part of what I (and many) people like about the plugin.

Another idea, though hacky, would be to add artificial delay after a file has been opened

maybe a bit less hacky would be to check file creation date before running the sync, and only run the sync if the fiel creation is x seconds ago – I assume it is during that time span that templater runs it's templates?

@dvcrn
Copy link
Owner

dvcrn commented Feb 14, 2022

Let's try to make the file-open hook optional and see if that solves some of these issues. I also like the functionality that a new file automatically has the headline synced on creation, so I don't want to mess with that too much

From my understanding templater is creating the file first, then inserting the templated content? So both plugins overwrite each other. The best would be if there was some way to detect that a file has been created by templater...

@JohnPaton
Copy link

JohnPaton commented Feb 14, 2022

As far as I know Templater doesn't create files itself, it just listens for the file creation event and fills the new file with content

image

@dvcrn
Copy link
Owner

dvcrn commented Feb 15, 2022

Ah I see, so it hooks into file creation... Wonder if we can extract that setting somehow (or detect that it's enabled) and then change the behavior of filenamen-heading-sync

@chrisgrieser chrisgrieser changed the title Bug: With enabled, Templater Folder Templates stop working Bug: When enabled, Templater Folder Templates stop working Feb 27, 2022
@chrisgrieser
Copy link
Author

Automatically changing behavior if this plugin depending on the templater setting would be great, but I think a simple toggle in the settings of this plugin would ahead be a good start.

@dvcrn
Copy link
Owner

dvcrn commented Mar 11, 2022

Hey folks! 1.6.0 is out with an option to disable the file-open hook

Screen Shot 2022-03-11 at 11 32 58

Please give it a go and check if this fixes issues with templater

@chrisgrieser
Copy link
Author

seems it fixes the issue for me! :)

@dvcrn
Copy link
Owner

dvcrn commented Mar 14, 2022

Great to hear! Let's wait for some of the others to report back, then we can close this for now.

Would be good if we can find some automatic solution to detect templater

@rdimaio
Copy link

rdimaio commented Mar 21, 2022

Disabling the "Use File Open Hook" fixes the issue for me as well. Thanks a lot :)

@dvcrn
Copy link
Owner

dvcrn commented Mar 22, 2022

Great, I'll close this for now

@dvcrn dvcrn closed this as completed Mar 22, 2022
@dobrealeksa
Copy link

Disabling the "Use File Open Hook" does not fix the issue, at least not anymore... 🥲

@dvcrn
Copy link
Owner

dvcrn commented Dec 26, 2022

I've created an issue over at the templater repository - SilentVoid13/Templater#924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants