summaryrefslogtreecommitdiff
path: root/ext/bg/data/default-anki-field-templates.handlebars
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-28 21:17:10 -0500
committerGitHub <noreply@github.com>2021-01-28 21:17:10 -0500
commite610a62ceb07313c581a0bd2d5c8ebbc7c39ba4f (patch)
tree2c798350f52f47cc64353c12e54c43ebf2a535fc /ext/bg/data/default-anki-field-templates.handlebars
parented0c0c20c095ac693dac3f1c4145e4c8dc83601a (diff)
Refactor anki field templates (#1323)
* Update glossary and glossary-single * Define patch * Create TemplatePatcher * Add test
Diffstat (limited to 'ext/bg/data/default-anki-field-templates.handlebars')
-rw-r--r--ext/bg/data/default-anki-field-templates.handlebars53
1 files changed, 22 insertions, 31 deletions
diff --git a/ext/bg/data/default-anki-field-templates.handlebars b/ext/bg/data/default-anki-field-templates.handlebars
index a0aff5d2..94553183 100644
--- a/ext/bg/data/default-anki-field-templates.handlebars
+++ b/ext/bg/data/default-anki-field-templates.handlebars
@@ -2,26 +2,23 @@
{{~#unless brief~}}
{{~#scope~}}
{{~#set "any" false}}{{/set~}}
- {{~#if definitionTags~}}{{#each definitionTags~}}
- {{~#if (op "||" (op "!" ../data.compactTags) (op "!" redundant))~}}
+ {{~#each definitionTags~}}
+ {{~#if (op "||" (op "!" @root.compactTags) (op "!" redundant))~}}
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
{{name}}
{{~#set "any" true}}{{/set~}}
{{~/if~}}
{{~/each~}}
{{~#if (get "any")}})</i> {{/if~}}
- {{~/if~}}
{{~/scope~}}
- {{~#if only~}}({{#each only}}{{{.}}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
+ {{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
{{~/unless~}}
- {{~#if glossary.[1]~}}
- {{~#if compactGlossaries~}}
- {{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{#unless @last}} | {{/unless}}{{/each}}
- {{~else~}}
- <ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul>
- {{~/if~}}
+ {{~#if (op "<=" glossary.length 1)~}}
+ {{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{/each}}
+ {{~else if @root.compactGlossaries~}}
+ {{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{#unless @last}} | {{/unless}}{{/each}}
{{~else~}}
- {{~#multiLine}}{{glossary.[0]}}{{/multiLine~}}
+ <ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul>
{{~/if~}}
{{/inline}}
@@ -92,33 +89,27 @@
{{~/if~}}
{{/inline}}
-{{#*inline "glossary"}}
+{{~#*inline "glossary"~}}
<div style="text-align: left;">
- {{~#if modeKanji~}}
- {{~#if definition.glossary.[1]~}}
- <ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol>
- {{~else~}}
- {{definition.glossary.[0]}}
- {{~/if~}}
- {{~else~}}
- {{~#if group~}}
- {{~#if definition.definitions.[1]~}}
- <ol>{{#each definition.definitions}}<li>{{> glossary-single brief=../brief compactGlossaries=../compactGlossaries data=../.}}</li>{{/each}}</ol>
+ {{~#scope~}}
+ {{~#if (op "===" definition.type "term")~}}
+ {{~> glossary-single definition brief=brief ~}}
+ {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
+ {{~#if (op ">" definition.definitions.length 1)~}}
+ <ol>{{~#each definition.definitions~}}<li>{{~> glossary-single . brief=../brief ~}}</li>{{~/each~}}</ol>
{{~else~}}
- {{~> glossary-single definition.definitions.[0] brief=brief compactGlossaries=compactGlossaries data=.~}}
+ {{~#each definition.definitions~}}{{~> glossary-single . brief=../brief ~}}{{~/each~}}
{{~/if~}}
- {{~else if merge~}}
- {{~#if definition.definitions.[1]~}}
- <ol>{{#each definition.definitions}}<li>{{> glossary-single brief=../brief compactGlossaries=../compactGlossaries data=../.}}</li>{{/each}}</ol>
+ {{~else if (op "===" definition.type "kanji")~}}
+ {{~#if (op ">" definition.glossary.length 1)~}}
+ <ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol>
{{~else~}}
- {{~> glossary-single definition.definitions.[0] brief=brief compactGlossaries=compactGlossaries data=.~}}
+ {{~#each definition.glossary~}}{{.}}{{~/each~}}
{{~/if~}}
- {{~else~}}
- {{~> glossary-single definition brief=brief compactGlossaries=compactGlossaries data=.~}}
{{~/if~}}
- {{~/if~}}
+ {{~/scope~}}
</div>
-{{/inline}}
+{{~/inline~}}
{{#*inline "glossary-brief"}}
{{~> glossary brief=true ~}}