From 81390468b95e786e2aabb41ddcbdd91ab9b345c3 Mon Sep 17 00:00:00 2001
From: Kuuuube <61125188+Kuuuube@users.noreply.github.com>
Date: Sun, 12 May 2024 22:16:02 -0400
Subject: Add glossary-first handlebars (#921)
* Add glossary-first handlebars
* Add docs
* Fix missing /if
* Write handlebars test data
---
.../anki-field-templates-upgrade-v35.handlebars | 33 ++++++++++++++++++++++
.../default-anki-field-templates.handlebars | 24 ++++++++++++++++
2 files changed, 57 insertions(+)
create mode 100644 ext/data/templates/anki-field-templates-upgrade-v35.handlebars
(limited to 'ext/data')
diff --git a/ext/data/templates/anki-field-templates-upgrade-v35.handlebars b/ext/data/templates/anki-field-templates-upgrade-v35.handlebars
new file mode 100644
index 00000000..e71efcf8
--- /dev/null
+++ b/ext/data/templates/anki-field-templates-upgrade-v35.handlebars
@@ -0,0 +1,33 @@
+{{<<<<<<<}}
+{{#*inline "glossary-brief"}}
+ {{~> glossary brief=true ~}}
+{{/inline}}
+{{=======}}
+{{#*inline "glossary-brief"}}
+ {{~> glossary brief=true ~}}
+{{/inline}}
+
+{{~#*inline "glossary-first"~}}
+
+ {{~#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)~}}
+ {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~else~}}
+ {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~/if~}}
+ {{~/if~}}
+ {{~/scope~}}
+
+{{~/inline~}}
+
+{{#*inline "glossary-first-no-dictionary"}}
+ {{~> glossary-first noDictionaryTag=true ~}}
+{{/inline}}
+
+{{#*inline "glossary-first-brief"}}
+ {{~> glossary-first brief=true ~}}
+{{/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 3f20f8ee..53dab1c1 100644
--- a/ext/data/templates/default-anki-field-templates.handlebars
+++ b/ext/data/templates/default-anki-field-templates.handlebars
@@ -141,6 +141,30 @@
{{~> glossary brief=true ~}}
{{/inline}}
+{{~#*inline "glossary-first"~}}
+
+ {{~#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)~}}
+ {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~else~}}
+ {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~/if~}}
+ {{~/if~}}
+ {{~/scope~}}
+
+{{~/inline~}}
+
+{{#*inline "glossary-first-no-dictionary"}}
+ {{~> glossary-first noDictionaryTag=true ~}}
+{{/inline}}
+
+{{#*inline "glossary-first-brief"}}
+ {{~> glossary-first brief=true ~}}
+{{/inline}}
+
{{#*inline "kunyomi"}}
{{~#each definition.kunyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}}
{{/inline}}
--
cgit v1.2.3