-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
[Obsidian 1.8.5] app.fileManager.processFrontMatter stop working #1540
Comments
I can reproduce when using the "replace templates in the active file" command, but not the "open insert template modal" command, which is the more commonly used command. Are you seeing the same? Do you have a use case for "replace template in the active file" outside of testing? I am also on Obsidian 1.8.5, Templater 2.9.3. |
I use mostly "replace templates in the active file" than open insert template modal :'). I have even a quick shortcuts for it, so i can write template and quick replace the text. |
In that case, I can recommend the following. <%*
const file = tp.file.find_tfile(tp.file.title);
await tp.hooks.on_all_templates_executed(async () => {
await tp.app.fileManager.processFrontMatter(file, (frontmatter) => {
frontmatter["key"] = "T";
});
});
-%> Let me know if that doesn't work and I'm happy to explore more options with you! Closing since I don't expect we'll be able to fix the original issue, and will instead rely on this workaround. |
Thank you! It was what I have done when discovering the hook :) |
Plugin Information
Describe the Bug
When using the following code:
The frontmatter does not get updated. Instead, it appears to be modified and then immediately reverted, as if Obsidian restores the file's original contents.
Expected Behavior
The frontmatter should be updated with the new key-value pair.
Screenshots
Screen recording
Additional Context
The issue is reproducible in Obsidian's sandbox mode.
The text was updated successfully, but these errors were encountered: