Package: ateto
atetois a set of tools to write templates outside of Anki.Why ?It’s a collection of scripts I try to reorganize. It started with the Anki
addon calledTemplates Import / Export, a python tool,Anki Template
Testerand now … look at
this ! Yes, the name is not much creative.In short, it can :export models templates(HTML and CSS) from Anki to
files (inside$XDG_DATA_HOME/ateto)take some note as samples from Anki andtest the templateswith them (producing a file likehtml_output/Basic.html)importmodels templates and some shared medias (like_base.css)
to AnkiFrom the command line, with something like this:ateto sync # export from anki
ateto compile # write test templates files
ateto sync -i # import in ankiThere is also a shorthand command calledatetoand a “watcher”. It’s useful
to compile test templates at each modification:ateto watchInstallationThis should work:python -m pip install atetoRequirementsRight now it depends on theAnkiConnectAnki addon and
anki-templates-tester that I put inside this project to keep things simple.Default working directoryThe default working directory is$XDG_DATA_HOME/ateto(something like~/.local/share/ateto). The templates of each Anki “note type” (or “model”)
are stored inmodels_export.Simple how toSync templates with AnkiFirst, while Anki is running, we need to export models templates with
AnkiConnect:ateto syncIf we change some files inmodels_export, we can import them in Anki with:ateto sync -iCompile test templatesWe need to get some sample data from Anki and then compile templates. But
first, open Anki and tag some notes withtemplate_test_data:ateto populate
ateto compileImages and CSS or JS assetsIf there is missing images run:ateto linkAll files under themodels_export/_mediasdirectory will be linked inhtml_outputwithcompile -m:ateto compile -mBut you have to create them first.Supertemplatesmodels_exportcontains template export of Anki notes templates. It’s basic
HTML. There is “supertemplates” : it’s Jinja2 templates that we can use to
generate the models, they are insupertemplatesfolder.To build the supertemplates use-soption withcompile:ateto compile -sHTML and CSS files in supertemplates are processed, thenmodels_exportare
converted tohtml_output.WatcherIt’s my favorite part. When I’m working on some templates, I want modifications
to be automatically compiled in templates and output HTML some I usewatchcommand:ateto watchAnd I want it all, supertemplates, medias and images. I want them to be
imported in Anki too. Images are only linked when starting, not watchedateto watch -aiMoreDebug modewatchandcompilecommands can be run with debug mode (-doption).
This will run supertemplates with a context whereis_debug=True. It’s
useful to debug AnkiDroid with something like this in templates files{% if is_debug %}
  <script src="https://cdn.jsdelivr.net/npm/eruda"></script>
  <script>eruda.init();</script>
{% endif %}File treeSo at the end, in$XDG_DATA_HOME, we have 4 main folders* /supertemplatesModelName/ directories.jinja files.html filesstyle.css file_medias/ directory (optional).css files.js files/models_exportModelName/ directoriesCardName.html filesstyle.css file_medias/ directory (optional).css files.js files/dataModelName.yaml filesModelName_override.yaml optional files/html_outputModelName.html filesModelName.css files.css files linked from models_export/_medias.js files linked from models_export/_medias.png, .jpg, etc. files linked from anki_collectionThe content ofsupertemplatesis only created by hand and
compiled intomodels_export.All the content ofmodels_exportis synced with Anki (Ankiconnect). _medias
are treated with a special procedure.The content ofdatais populated from Anki. _override.yaml files are
created by hand if necessary.html_outputis the result of different actions :ModelName.html and ModelName.css files are the result ofmodels_exportanddatafilesothers CSS or JS are linked tomodels_export/_mediasimages are linked to the Anki collection