If there was a way to capture the script’s function like this const {createButton} = app.plugins.plugins["buttons"]; it would be perfect, but I am not sure how to access Templater’s API and it’s scripts or even the tp object. If I had access to tp inside the dataview code block I could simply use tp.user.script(), and that would work as well.
It doesn’t necessarily needs to be a Templater script, all I need is to run a function that I created on a separate file, so I can change the functionally of all buttons on a single place, instead of going to each note that has that button and changing the method. I have no idea how to do it though. Any help and ideas would be appreciated.
I saw your post a little earlier on, but its been a busy day, so good for you that you found out of it. I first saw the Templater api referenced by @AlanG here: How to calculate my work hours - #8 by AlanG
And there he doesn’t pull out a single function like you do, which indeed is a neat trick, but he rather pulls out the “default” tp object:
And then uses the various functions like you do in a template, like doing tp.system.prompt(). I kind of like that approach, but this a matter of personal preferences.
Whilst on a similar topic, I would also like to mention two alternatives which might be useful for other use cases:
Using dv.view() functions, which is also a way to access a user defined javascript function. It’s the dataview alternative, so it’s a little directed towards producing a view of something with the possibility to attach dedicated CSS as part of the function. See Codeblock Reference - Dataview
So depending on your use case, either of these could be slightly better suited for the task at hand, but I just wanted to mention them to kind of broaden the view of alternatives available.