From 9b1fb837408ef70c5d54dfea54e288b6e0d963ba Mon Sep 17 00:00:00 2001 From: Yannick Mau Date: Fri, 13 Mar 2020 23:40:27 +0100 Subject: [PATCH 1/2] Add card name option to model template --- plugin/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/__init__.py b/plugin/__init__.py index d6bc9f8..700e045 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -642,7 +642,11 @@ class AnkiConnect: # Generate new card template(s) cardCount = 1 for card in cardTemplates: - t = mm.newTemplate(anki.lang._('Card ' + str(cardCount))) + cardName = 'Card ' + str(cardCount) + if 'Name' in card: + cardName = card['Name'] + + t = mm.newTemplate(anki.lang._(cardName)) cardCount += 1 t['qfmt'] = card['Front'] t['afmt'] = card['Back'] From 3a1cbef4e5adea971b42557e5fbea7509c7d1cf4 Mon Sep 17 00:00:00 2001 From: Yannick Mau Date: Fri, 13 Mar 2020 23:46:19 +0100 Subject: [PATCH 2/2] Add name field to the documentation --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bee71ef..7e67fd9 100644 --- a/README.md +++ b/README.md @@ -709,7 +709,8 @@ guarantee that your application continues to function properly in the future. * **createModel** Creates a new model to be used in Anki. User must provide the `modelName`, `inOrderFields` and `cardTemplates` to be - used in the model. + used in the model. Optionally the `Name` field can be provided for each entry of `cardTemplates`. By default the + card names will be `Card 1`, `Card 2`, and so on. *Sample request* ```json @@ -722,6 +723,7 @@ guarantee that your application continues to function properly in the future. "css": "Optional CSS with default to builtin css", "cardTemplates": [ { + "Name": "My Card 1", "Front": "Front html {{Field1}}", "Back": "Back html {{Field2}}" } @@ -772,7 +774,7 @@ guarantee that your application continues to function properly in the future. ], "tmpls":[ { - "name":"Card 1", + "name":"My Card 1", "ord":0, "qfmt":"", "afmt":"This is the back of the card {{Field2}}",