Omphaloskepsis-2/layouts/shortcodes/abbr.html
2023-06-30 21:16:59 -06:00

35 lines
1.7 KiB
HTML

{{- $abbr := .Get 0 -}}
{{- $mode := default "shortTitle" ( .Get 1 ) -}}
{{- with ( index $.Site.Data.abbreviations $abbr ) -}}
{{- if ( or ( eq $mode "shortTitle" ) ( eq $mode "shortTitlePl" ) ) -}}
<abbr class="abbr" title="
{{- if ( eq $mode "shortTitle" ) -}}
{{- .longTitle -}}
{{- else if ( eq $mode "shortTitlePl" ) -}}
{{- with .longTitlePl -}}{{- . -}}{{- else -}}{{- .longTitle -}}s{{- end -}}
{{- end -}}
">
{{- if ( eq $mode "shortTitle" ) -}}
{{- .shortTitle | safeHTML -}}
{{- else if ( eq $mode "shortTitlePl" ) -}}
{{- with .shortTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .shortTitle | safeHTML -}}s{{- end -}}
{{- end -}}
</abbr>
{{- else if ( or ( eq $mode "longtitle" ) ( eq $mode "longTitlePl" ) ) -}}
{{- if ( eq $mode "longTitle" ) -}}
{{- .longTitle | safeHTML -}}
{{- else if ( eq $mode "longTitlePl" ) -}}
{{- with .longTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitle | safeHTML -}}s{{- end -}}
{{- end -}}
{{- else if ( or ( eq $mode "fullTitle" ) ( eq $mode "fullTitlePl" ) ) -}}
{{- if ( eq $mode "fullTitle" ) -}}
{{- .longTitle | safeHTML -}}&nbsp;(<abbr>{{- .shortTitle | safeHTML -}}</abbr>)
{{- else if ( eq $mode "fullTitlePl" ) -}}
{{- with .longTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitle | safeHTML -}}s{{- end -}}
&nbsp;(<abbr>{{- with .shortTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .shortTitle | safeHTML -}}s{{- end -}}</abbr>)
{{- end -}}
{{- end -}}
{{- else -}}
{{- errorf "No definition found for abbreviation '%q'" $abbr -}}
{{- end -}}