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

AnkiWeb addon 1159566613

Generates Anki card templates through arbitrary Python code embedded in HTML attributes, plus a domain-specific generator library for conditionally modifying templates.
AI-generated summary; may contain mistakes.

card-templatesbeta

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
1 (πŸ‘ 1 Β· πŸ‘Ž 0)
Updated
2020-03-09
Anki versions
unknown
License
GPL-3.0 (from the license file in the package)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python, CSS, JSON, HCL, Batchfile
Description language
en

Maintenance

active

  • Last update or commit: 2026-07-14 (110 days before the snapshot).
  • Commits in the last year: 10.
  • Issues: 0 open, 3 closed.
  • Pull requests: 1 open, 0 merged.
  • Median first response: 1 hour (4 answered issues and pull requests).

Will it work on my Anki?

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

Loading…

Similar addons

Code Your Answer

Lets you type code answers in an IDE-style field during review and shows an instant character-level diff against the solution, with syntax highlighting and coding shortcuts.

formattingshortcutscard-templatesquiz

1 votes 21% approval πŸ‘ 1 Β· πŸ‘Ž 0 ⭐ 3 Anki 25.02.7~ Updated 2026-06-19
Speech Assigner

Adds automatic text-to-speech playback and assigns TTS tags to selected fields per note type, without editing templates, supporting batch processing and language-specific voices.

review-flownote-managementcard-templatesaccessibility

1 votes 21% approval πŸ‘ 1 Β· πŸ‘Ž 0 ⭐ 0 Anki 25.09.2~ Updated 2025-12-14

Description

This add-on allow to use Python to generate card's template. It also provide an domain specific language to generate templates.

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