Using mustache for live demo (unescape JSON data)
badlydrawnrob opened this issue · 0 comments
badlydrawnrob commented
TL;DR
- Stick to plain HTML and Markdown
- Be careful what code you're adding to Anki fields!
- Make sure you escape your HTML if you're doing things the professional way (making your own
build/
folder)- You can use an online tool to do this
Anki field templates and Mustache.js
Mustache javascript library is the closest representation of the Anki app field templates that I can find. It's not exactly the same as the docs so beware of bugs.
We can generate live card previews that are compiled from the demo/
folder and the .json
file populates the content. The Anki cards that live in the Anki app are generated in cards/
(the demo/
folder is just for show!)
{{{☆ Syntax}}}
Triple brackets are used, to unescape json html in the live demo cards- Without it, syntax blocks are interpreted as strings (not raw html)
- HTML, or speech marks (
" "
) in json must be escaped before they're compiled.
- Triple brackets will not work in the Anki app
- I'd advise you to stick to plain Markdown and HTML in the Anki App, javascript can break things.
- Also be careful when importing other people's decks, especially if they include javascript.