Better template loading, word page

See https://stackoverflow.com/a/11468132
This commit is contained in:
Elnu 2023-07-22 16:26:40 -07:00
parent f558d7f0c1
commit e70916c6c1
11 changed files with 236 additions and 87 deletions

View file

@ -0,0 +1,23 @@
{{ define "entry" }}
<div class="box">
<h3>
{{- if .Kanji -}}
<a href="/word/{{ .Kanji }}"><ruby>{{- .Kanji -}}<rp>(</rp><rt>{{- .Reading -}}</rt><rp>)</rp></ruby></a>
{{- else -}}
{{- .Reading -}}
{{- end -}}
</h3>
{{- $count := len .Definitions -}}
{{ if eq $count 1 -}}
<p>{{- template "definition" (index .Definitions 0) -}}</p>
{{- else if ne $count 0 -}}
<ol>
{{- range .Definitions }}
<li>
{{ template "definition" . }}
</li>
{{- end }}
</ol>
{{- end }}
</div>
{{ end }}