From 2d191bfdbd955a363e7afdc79c7a2b4b11a2e9b7 Mon Sep 17 00:00:00 2001 From: StefanVukovic99 Date: Sun, 5 May 2024 02:30:09 +0200 Subject: add single dictionary handlebars (#814) * add single dictionary handlebars * fix dicts with kanji in title * sort * rename to single-glossary-XYZ * add brief and no dict variants * add docs, only terms no kanji * allow testing single dict handlebars * remove empty comment --- .../anki-field-templates-upgrade-v34.handlebars | 59 ++++++++++++++++++++++ .../default-anki-field-templates.handlebars | 20 ++++++-- 2 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 ext/data/templates/anki-field-templates-upgrade-v34.handlebars (limited to 'ext/data') diff --git a/ext/data/templates/anki-field-templates-upgrade-v34.handlebars b/ext/data/templates/anki-field-templates-upgrade-v34.handlebars new file mode 100644 index 00000000..5538df85 --- /dev/null +++ b/ext/data/templates/anki-field-templates-upgrade-v34.handlebars @@ -0,0 +1,59 @@ +{{<<<<<<<}} +{{~#*inline "glossary"~}} +
+ {{~#scope~}} + {{~#if (op "===" definition.type "term")~}} + {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}} + {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}} + {{~#if (op ">" definition.definitions.length 1)~}} +
    {{~#each definition.definitions~}}
  1. {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
  2. {{~/each~}}
+ {{~else~}} + {{~#each definition.definitions~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/each~}} + {{~/if~}} + {{~else if (op "===" definition.type "kanji")~}} + {{~#if (op ">" definition.glossary.length 1)~}} +
    {{#each definition.glossary}}
  1. {{.}}
  2. {{/each}}
+ {{~else~}} + {{~#each definition.glossary~}}{{.}}{{~/each~}} + {{~/if~}} + {{~/if~}} + {{~/scope~}} +
+{{~/inline~}} +{{=======}} +{{~#*inline "glossary"~}} +
+ {{~#scope~}} + {{~#if (op "===" definition.type "term")~}} + {{~#unless (op "&&" selectedDictionary (op "!=" selectedDictionary definition.dictionary))~}} + {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}} + {{~/unless~}} + {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}} + {{~#if (op ">" definition.definitions.length 1)~}} +
    + {{~#each definition.definitions~}} + {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}} +
  1. + {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}} +
  2. + {{~/unless~}} + {{~/each~}} +
+ {{~else~}} + {{~#each definition.definitions~}} + {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}} + {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}} + {{~/unless~}} + {{~/each~}} + {{~/if~}} + {{~else if (op "===" definition.type "kanji")~}} + {{~#if (op ">" definition.glossary.length 1)~}} +
    {{#each definition.glossary}}
  1. {{.}}
  2. {{/each}}
+ {{~else~}} + {{~#each definition.glossary~}}{{.}}{{~/each~}} + {{~/if~}} + {{~/if~}} + {{~/scope~}} +
+{{~/inline~}} +{{>>>>>>>}} \ No newline at end of file diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 3ca7ba18..3f20f8ee 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -101,12 +101,26 @@
{{~#scope~}} {{~#if (op "===" definition.type "term")~}} - {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}} + {{~#unless (op "&&" selectedDictionary (op "!=" selectedDictionary definition.dictionary))~}} + {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}} + {{~/unless~}} {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}} {{~#if (op ">" definition.definitions.length 1)~}} -
    {{~#each definition.definitions~}}
  1. {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
  2. {{~/each~}}
+
    + {{~#each definition.definitions~}} + {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}} +
  1. + {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}} +
  2. + {{~/unless~}} + {{~/each~}} +
{{~else~}} - {{~#each definition.definitions~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/each~}} + {{~#each definition.definitions~}} + {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}} + {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}} + {{~/unless~}} + {{~/each~}} {{~/if~}} {{~else if (op "===" definition.type "kanji")~}} {{~#if (op ">" definition.glossary.length 1)~}} -- cgit v1.2.3