Simple way to support source control and any external editor for templates

Unless I’m hallucinating there is a general fix achievable in 3, relatively, simple steps:

  1. Create files for each template in an external folder according to some naming structure like:
    basefolder/{notetype}/{cardtype}.css
    basefolder/{notetype}/{cardtype}_front.mustache
    basefolder/{notetype}/{cardtype}_back.mustache

  2. Whenever a template changes in Anki, update the corresponding files

  3. Whenever a file changes push the changes into Anki and refresh the open previewer.

Now one could use any editor without ever editing in Anki and get live updates on the effect of the changes. One could manage and share templates via git repositories. One could set up any type of build or even a site generator to create one’s templates. As long as it eventually updates those files things would just work.

Is there some reason why this would not work or would be hard to implement?

If someone could point me in the right direction on how to watch for changes in the templates within Anki, and read/write data from them, I might just give implementing this as an addon myself a shot. I might be dreaming, but it seems like it should be reasonably easy :slight_smile:

I’m 100% sure someone wrote an add-on that works like this, but I can’t remember its name now. Will post an update when I find it.

OK, here it is: Anki Card Template Editor in VS Code using AnkiConnect
Doesn’t work exactly as you describe but probably close enough.

1 Like

Thanks a lot for the tip. It is appreciated :slight_smile:

But, while your suggestion enables using one specific external editor it neither supports the tools I prefer nor enables me to manage my templates in a git repository.

What I am suggesting here is something quite different. Something that would enable the use of any external editor as well as the use of source control tools to manage ones templates.

Heck, I made a mistake 20 edits ago: Just revert that commit in git and all my templates are instantly updated. I want that type of functionality so badly :slight_smile: