generated from ElnuDev/go-project
Better template loading, word page
See https://stackoverflow.com/a/11468132
This commit is contained in:
parent
f558d7f0c1
commit
e70916c6c1
11 changed files with 236 additions and 87 deletions
3
dict/templates/partials/definition.html
Normal file
3
dict/templates/partials/definition.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{- define "definition" -}}
|
||||
{{ if .PartOfSpeech }}<small><chip>{{ .PartOfSpeech }}</chip></small><br>{{ end }}{{ .Definition -}}
|
||||
{{ end }}
|
23
dict/templates/partials/entry.html
Normal file
23
dict/templates/partials/entry.html
Normal 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 }}
|
23
dict/templates/partials/entryfull.html
Normal file
23
dict/templates/partials/entryfull.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{{ define "entryfull" }}
|
||||
<div class="box">
|
||||
<h3>
|
||||
{{- if .Kanji -}}
|
||||
<ruby>{{- .Kanji -}}<rp>(</rp><rt>{{- .Reading -}}</rt><rp>)</rp></ruby>
|
||||
{{- 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 }}
|
11
dict/templates/partials/search.html
Normal file
11
dict/templates/partials/search.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{- define "search" -}}
|
||||
<p><i>{{ if .Truncated }}Truncated results, showing first {{ .Count }}{{ else }}{{ if eq .Count 0 }}No results{{ else }}{{ .Count }} result{{ if ne .Count 1}}s{{ end }}{{ end }}{{ end }}.</i></p>
|
||||
{{ range .ExactResults -}}
|
||||
{{- template "entry" . -}}
|
||||
{{- end }}
|
||||
{{ if and (ne (len .ExactResults) 0) (ne (len .OtherResults) 0) }}<hr>{{ end }}
|
||||
{{ range .OtherResults -}}
|
||||
{{ template "entry" . }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- template "search" . -}}
|
1
dict/templates/partials/sitetitle.html
Normal file
1
dict/templates/partials/sitetitle.html
Normal file
|
@ -0,0 +1 @@
|
|||
{{ define "sitetitle" }}jidict{{ end }}
|
Reference in a new issue