Templater life cycle hooks

I’d like to write a user function that gets called before and/or after Templater inserts (and processes) a template. Does Templater support these kind of “lifecycle” events that I can chain a user function to?

Thank you!

I’ve not heard of any such functionality, but there is nothing in the way of you adding such functions to the start and end of your templates.

The only variant I’ve heard of is the Settings > Templater > Startup Templates, where you’re able to set a template which gets executed once when Templater starts. They don’t have any output, but can be useful (it says) to set up templates adding hooks to obsidian events for example.

I know some also have used these for executing “random” javascript code in an execution command block of such a template.

These are just run once though every time Templater starts. That is either when Obsidian starts (or force reloaded (I think triggers this too)), or Templater is enabled.


To expand on holroy’s reply, I have a bunch of user-functions that I call at various places throughout my template code. I put common template logic in these user functions so that I can reuse them in multiple templates.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.