This seems to be the correct incantation of tp, but it does depend on Templater having run at least once before in your vault since the last startup of Obsidian.
So try inserting some random template somewhere in your vault, and then check this code again. If it now works, this issue is what has happened to you. To avoid it in the further, there is a simple trick of making an empty template, and set that template as a startup template for Templater when you restart your Obsidian. That way, it would always give the current functions object its value needed for accessing the Templater API from other places.
Another alternative I found for situations like this when one doesn’t want the Templater plugin to have been run at least once:
// get access to the internal modules
let tp = app.plugins.plugins["templater-obsidian"].templater;
tp = tp.functions_generator.internal_functions.modules_array;
// get an instance of the date module
let tp_date = tp.find(m => m.name == "date");
// METHOD 1 of getting access to a specific module function
let tp_now = tp_date.generate_now();
// or METHOD 2 of getting access to a specific module function
// let tp_now = tp_date.static_functions.get("now");
// print the output of that function
dv.el("p", tp_now());
I do notice sometimes these class calls do work, and I have seen both instances where current_functions_object is defined and undefined… Assuming that I have somehow ran tp since last startup.
However my issue seems to be when tp tries to construct itself. As it loads the scripts that call for it to use itself…
Right now I have to remove the sub folder that contains my classes from scripts for any of my other template scripts to work. As soon as I add them back in, Community cannot be defined becase it cannot define rObject.
I am trying to expose javascript class modules from the tp.user functions.
Have you tried using the CustomJS plugin? Ot potentially utilising the startup template of Templater?
I’m not sure how easy it is to make the user functions trigger in a given order. You might need to either import/require stuff from your rObjects, or possibly you could use alphabetical order to trigger when they’re loaded.
I failed to realise this was an extension on an already answered question. Please repost as a new thread, including what you’ve learned and/or tried so far, @waniel .