anki_asset_manager

Simplify managing your card templates!

MIT License

Stars
4

Asset Manager makes it easier for you to manage scripts on your note templates.

Features

Functionalites Script Tab Script Config

Insert Stub: Exchanges the Div Element with an HTML stub. This makes it is easier to edit the card types, without having to scroll through all the JavaScript, but Asset Manager will still the remember the position in the document for the scripts to insert. Label (not depicted): Used to merge multiple code snippets into one script "unit", this takes effect for insertion positions "Into template", and "As External Script". The resulting script will adopt the name, version, and conditions from the uppermost snippet in the list. Insertion Positions: As External Document: Will copy the script to media folder and paste a script element referencing this external script. Note, that this means that scripts may execute asynchronously and out-of-order!Document Head: Uses an Anki webhook to inject the script into the document header. Will not work on mobile!Document Body: Uses an Anki webhook to inject the script into the document body. Will not work on mobile!Into Template: Will inject the complete script into the template body. This will ensure that scripts are executed immediately and in order. Insertion Conditions: Restrict to a specific side: ["side", "=", "front"] or ["side", "=", "back"]Restrict to a specific card: ["card", "=", "NameOfTheCard"]Combine conditions: "&" stands for conjunctions (and), "|" stands for disjunction (or): ["&", ["card", "=", "Card 1"], ["side", "=", "front"]]

HTML Tab HTML Config

Labels: Labels identify your HTML "snippets", or "fragments". Insertion begins with the "Front" label for the frontside of the card, and "Back" for the backside of the card. When using a label like {{%MyLabel}} in the template, it will be replaced with a fragment with a label "MyLabel". Special Labels: There are multiple special labels defined, which you can use. These always start with a small letter: {{%idx: will be replaced with the numerical ID of the card{{%cardidx}}: will be replaced with an ID that is found on the tail of the card name. If the card is named "Card 25", this value will evaluate to 25, even if it is in first position.{{%scripts}}: This will evaluate to the output of the JavaScript functionality of the add-on Insertion Conditions: Same as above. This way you can make a label {{%MyLabel}} be replaced with a different code snippet depending on the side of the card, or the card type name.

For Developers Asset Manager offers a hook for you to insert your own JavaScript snippet via your own add-on. That way you can easily offer your script, give it a name, version it, and update it through the AnkiWeb platform, without making users have to care about pasting the JavaScript to their templates, copy the code to the media folder, etc.

Examples include: Anki PersistenceJapanese Kanji RTX popup for note typesCloset For Anki

Updates 2020-12-22:

  • Fix insertion as external file
  • Add support for syntax check
  • Add support for minified insertion
  • Add support for extra button "Assets..." in editor (can be turned on in the add-on settings)

Support If you like my add-ons, you can consider supporting me. My add-ons will always be freely available for everybody, but what I can offer you is my sincere thanks, and first-hand technical support, if you have any questions/issues with my add-ons. At the same time it allows me to put more time and focus into developing these and making them as powerful and user-friendly as they are. Thanks for considering!

ko-fi.com/hgiesel patreon.com/hgiesel