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

Meta Bind using Templater (insert / replace) and operability with Templater hook (on_all_templates_executed) #319

Open
2 of 7 tasks
Robomunkie opened this issue May 8, 2024 · 1 comment
Labels
bug Undesired behavior caused by this plugin

Comments

@Robomunkie
Copy link

Robomunkie commented May 8, 2024

Please fill out these Check-boxes

  • I checked that the plugin is up to date
  • The issue persist with all other plugins and themes disabled

This Issue Occurs on

  • Windows
  • Linux
  • macOS
  • Android
  • iOS

Plugin Version

1.1.0

Describe the Issue

I use a "meta-bind-button" to perform a Templater action (eg. templater: true) through "replaceSelf" / "insertIntoNote" with the respective "replacement" or such button property set to a valid Templater script. In this script, I also setup a Templater hook using tp.hooks.on_all_templates_executed(async () => { ... }); in order to perform a final action upon completion of the Templater event being performed (see https://silentvoid13.github.io/Templater/internal-functions/internal-modules/hooks-module.html).

Unfortunately, the code contained within this Templater tp.hooks... block does not get executed automatically upon completion of the Templater event executed by the Meta Bind button I had created. I know that the Templater hook function itself has been setup to run correctly though, as I can trigger this hook event afterwards (and have executed the code I had setup within it) by forcing a "Templater: Replace templates in the active file" (ALT+R, on Windows) operation on the note containing my Meta Bind button and Templater action.

Steps to Reproduce

  1. Setup a Meta Bind button w/ Templater action, eg. "replaceSelf" :
style: primary
label: 'PRESS ME'
action:
   type: replaceSelf
   replacement: '/MYTEMPLATECODE'
   templater: true
  1. Setup a Templater code template (eg. "/MYTEMPLATECODE") :
<%*
   tp.hooks.on_all_templates_executed(async() => {
      console.log("Hello World!");
   });
-%>
Your button has been replaced!
  1. While watching the console, press the button - you will not see "Hello World!", but you will see the text "Your button has been replaced!" on your note, replacing your button.
  2. Now, trigger the Templater action (Templater: Replace templates in the active file) on your note containing your button.
  3. The console will then display "Hello World!", printed from the triggered hook code block configured above.

Expected Behavior

I would have expected that the code block contained within the Templater hook action would have been executed automatically upon completion of the Templater action operation of the Meta Bind button.

@Robomunkie Robomunkie added the bug Undesired behavior caused by this plugin label May 8, 2024
@mProjectsCode
Copy link
Owner

I haven't troubleshot this yet, but my first guess would be that this is either a result of how meta bind interacts with templater or an issue in templater.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behavior caused by this plugin
Projects
None yet
Development

No branches or pull requests

2 participants