Calling a plug function from Lua Expression

I’m trying to convert a block of space-lua to a self-contained plug on SilverBullet v2 that I’d like to share with the community.

The working principle is that you call a function in a Lua Expression block to render the interactive functionality of the plug (generated using the dom APIs), for example:

${ mystuff.renderMyTools() }

How do I achieve the same in a Plug? I’ve played with the .yaml file in the Plug template but I can’t seem to find a solution.

Any suggestions? Should I completely change my approach?

Thank you!

1 Like

OK, I just found the answer.

API/system → system.invokeFunction(“myplug.processData”, “input”, 123)

1 Like

If I understand you correctly, you can also make it a syscall, there are plenty of examples in the core plugs. On my phone rn so I can‘t provide an example, but then you don‘t need the invokeFunction thing

1 Like

I tried the syscall way as well but for some reason it wouldn’t find the function. Anyway, the invokeFunction works perfectly.

1 Like

Just for completeness sake of this thread, this is how it should work:

doSomething:
    path: "./path/to/file.ts:functionName"
    syscall: "yourplug.doSomething"
2 Likes