Edit card's template with python and a domain specific language

AnkiWeb addon 1159566613

Allows using Python to generate card templates and provides a domain-specific language for template generation.
AI-generated summary; may contain mistakes.

card-templatesbeta

Open on AnkiWeb GitHub Ask about alternatives

AnkiWeb

Rating
1 (πŸ‘ 1 Β· πŸ‘Ž 0)
Updated
2020-03-09
Anki versions
unknown
Description language
en

Maintenance

active

  • Last update or commit was 79 days before the snapshot (2026-07-14).

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.0–2020-03-09
History across monthly snapshots

Loading…

Similar addons

README

Template in Cards

This is a BETA version. If people want to help debugging and improving. It may change a lot and while I use this add-on a lot, I can't promise it to be fit for everyone (yet?)

An example of card generated using my add-on

Requirement

To use this add-on, you must have installed addon 802285486.

Links

To see a few examples of note type created using this add-on, go read: [examples/README.md] You should probably download this add-on and try those examples to understand how everything works.

Please, refer to documentation to learn how to use this add-on. I'll just give a few examples here.

Rationale

One of anki big limitation, as far as I'm concerned, is that templates can't have code in them. In my case, in a fixed note type, most of the templates are similar. Which means that I have to do a lot of copy-paste. And if I want to edit a part of the template, I have to edit once in each template.

If you know a little bit of Python and of HTML, you can use this add-on to ensure that your template is generated by some arbitrary Python code. The Python expression is given as an attribute of an HTML tag of the template. This ensure that the python code can remain in the template while never being shown in the card's content. This also means that you can recompile a template already compiled - which is pretty useful for debugging.

In order to easily write templates, this add-on also gives you a library/domain specicif language of basic component, called generators. Those generators allow you to change the template, depending on a lot of conditions.

Links, licence and credits

Key Value
Copyright Mostly https://github.com/hssm/anki-addons
Maintener Arthur Milchior arthur@milchior.fr
Based on Anki code by Damien Elmes anki@ichi2.net
License GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
Source in https://github.com/Arthur-Milchior/anki-template-card-type
Addon number 1159566613