Allow plugins to pipeline text through a single templating engine of choice

Use case or problem

There are multiple plugins that work with template engines, but each works with a different engine. Example: Templater, Obsidian Temple.

There are also other plugins that implement their own simple token-based templating. Example: Note Refactor.

These often ask to point to a template, but it becomes difficult to manage a single template that works with multiple plugins when plugins implement different templating systems.

Proposed solution

Provide an abstraction layer that allows plugins to pipeline to each other.

For example, a user who implements Templater could configure the Daily Notes plugin point to a note template file containing Templater commands AND configure the Daily Notes plugin to use Templater when generating the daily note. So when the user generates the daily note their Templater template commands are executed at the time the note is generated.

The same user could install the Note Refactor plugin and select from a series of choices – use the built-in simple template capability in the Note Refactor plugin, or call out to a template plugin of choice, in this case Templater. Then each time the user triggers the Note Refactor plugin it does everything it normally would except when it is time to generate the actual content into the new note it runs the contents through the chosen Templater plugin first so the Templater commands are executed and expanded.

This would of course require development on the part of the plugin developers, which means they would need some mechanism to pipe the information to the other plugin via the plugin API.

Doing this can increase the orthogonality of the components in the application, allowing us to combine multiple capabilities together more easily. cf Unix Philosophy which states (in part):

(i) Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features.

(ii) Expect the output of every program to become the input to another, as yet unknown, program.

Under this approach plugins like Daily Notes and Note Refactor could become drivers that can build the note and then pass the contents off to the next plugin in the pipeline before the content is pasted into the new note.

It also supports workflow definition since we can depend on a single universal template language/engine of our choosing that we know works across the platform, rather than a different engine in each plugin each with wildly differing capabilities and limitations.

Current workaround (optional)

None.

Related feature requests (optional)

14 Likes