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

2.3.2 broke my frontmatter processing template #1380

Closed
luckman212 opened this issue May 21, 2024 · 6 comments
Closed

2.3.2 broke my frontmatter processing template #1380

luckman212 opened this issue May 21, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@luckman212
Copy link

luckman212 commented May 21, 2024

Not sure exactly why yet, but this commit has broken my template that processes frontmatter. It no longer does the replacement. No error in console, frontmatter just flickers and gets replaced with the save content as before. I had to revert to 2.3.1.

Plugin information

  • OS: macOS
  • Templater version: 2.3.2
  • Obsidian version: 1.6.0 (Installer 1.5.12)
  • Template folder location: templates/
  • Timeout: 5
@luckman212 luckman212 added the bug Something isn't working label May 21, 2024
@Zachatoo
Copy link
Collaborator

Instead of a timeout I would recommend seeing if the hooks module resolves the issue for you. Try wrapping your editor changes in the on_all_templates_executed hook.

@luckman212
Copy link
Author

Thanks @Zachatoo but I updated my code to use hooks, and still can't get it to work in 2.3.2. I updated the top post to point to a new version of the script that uses tp.hooks.on_all_templates_executed()

@tobyfb
Copy link

tobyfb commented May 22, 2024

I might have a problem related to this. All my templates that use regex are built with the following structure / logic:

<%*
// based on the following example: https://github.com/SilentVoid13/Templater/discussions/255; relevant for other
var content = tp.file.content;
content = content.replace(/updated:(.*)/g, "updated: " + tp.date.now("YYYY-MM-DDTHH:mm:ss"));
var file = app.workspace.activeLeaf.view.file; // *get current file*
app.vault.modify(file, content); // *replace content with new content*
%>

This stopped working for me with 2.3.2.

I see a flicker where content is replaced as expected and then after a split second, things revert. It would be great to know if this is a bug or intended behavior and how I might need to adjust all of my templater templates for this to work.

@FeralFlora
Copy link

frontmatter just flickers and gets replaced with the save content as before

I was able to reproduce a similar issue when using "Create new note from template" with a simple template that includes tp.hooks.on_all_templates_executed to add frontmatter: #1309 (comment)

After the template insertion fix in 2.3.2, template insertion works (surprise!), but the frontmatter disappears when using "create new note from template" with the same template.

@luckman212
Copy link
Author

Not quite sure how, but I fixed my template and it's working with 2.3.2 now.

@Zachatoo
Copy link
Collaborator

Should be fixed in 2.3.3.

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

No branches or pull requests

4 participants