Omphaloskepsis-2/layouts/shortcodes/abbr.html
2023-08-07 18:23:46 -04:00

57 lines
2.9 KiB
HTML

{{- /**/ -}}
{{- $abbr := .Get 0 -}}
{{- $mode := default "shortTitle" ( .Get 1 ) -}}
{{- with ( index $.Site.Data.abbreviations $abbr ) -}}
<!-- Short titles (e.g. 'FBB') -->
{{- 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 .lang }} [{{ .longTitleTrans }}]{{- end -}}
"
{{- with .lang }} lang="{{ . }}"{{- end -}}
>
{{- if ( eq $mode "shortTitle" ) -}}
{{- .shortTitle | safeHTML -}}
{{- else if ( eq $mode "shortTitlePl" ) -}}
{{- with .shortTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .shortTitle | safeHTML -}}s{{- end -}}
{{- end -}}
</abbr>{{- /**/ -}}
<!-- Long titles (e.g. 'foo bar baz') -->
{{- else if ( or ( eq $mode "longTitle" ) ( eq $mode "longTitlePl" ) ) -}}
{{- if ( eq $mode "longTitle" ) -}}
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- $.longTitleTrans | safeHTML -}}">{{- end -}}
{{- .longTitle | safeHTML -}}
{{- if .lang -}}</i>{{- end -}}
{{- else if ( eq $mode "longTitlePl" ) -}}
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- with .longTitleTransPl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitleTrans | safeHTML -}}s{{- end -}}">{{- end -}}
{{- with .longTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitle | safeHTML -}}s{{- end -}}
{{- if .lang -}}</i>{{- end -}}{{- /**/ -}}
{{- end -}}
<!-- Full titles (e.g. 'foo bar baz (FBB)') -->
{{- else if ( or ( eq $mode "fullTitle" ) ( eq $mode "fullTitlePl" ) ) -}}
{{- if ( eq $mode "fullTitle" ) -}}
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- .longTitleTrans | safeHTML -}}">{{- end -}}
{{- .longTitle | safeHTML -}}
{{- if .lang -}}</i>{{- end -}}
&nbsp;(<abbr{{- with .lang }} lang="{{ . }}"{{- end -}}>{{- .shortTitle | safeHTML -}}</abbr>)
{{- else if ( eq $mode "fullTitlePl" ) -}}
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- with .longTitleTransPl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitleTrans | safeHTML -}}s{{- end -}}">{{- end -}}
{{- with .longTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitle | safeHTML -}}s{{- end -}}
{{- if .lang -}}</i>{{- end -}}
&nbsp;(<abbr{{- with .lang }} lang="{{ . }}"{{- end -}}>{{- with .shortTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .shortTitle | safeHTML -}}s{{- end -}}</abbr>){{- /**/ -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- errorf "No definition found for abbreviation '%q'" $abbr -}}
{{- end -}}
{{- /**/ -}}