Omphaloskepsis-2/layouts/shortcodes/abbr.html

58 lines
2.9 KiB
HTML
Raw Normal View History

2023-08-07 22:23:46 +00:00
{{- /**/ -}}
2023-07-01 03:16:59 +00:00
{{- $abbr := .Get 0 -}}
{{- $mode := default "shortTitle" ( .Get 1 ) -}}
{{- with ( index $.Site.Data.abbreviations $abbr ) -}}
2023-08-07 22:23:46 +00:00
<!-- Short titles (e.g. 'FBB') -->
2023-07-01 03:16:59 +00:00
{{- if ( or ( eq $mode "shortTitle" ) ( eq $mode "shortTitlePl" ) ) -}}
2023-08-07 22:23:46 +00:00
<abbr
class="abbr"
title="
{{- if ( eq $mode "shortTitle" ) -}}
2023-07-01 03:16:59 +00:00
{{- .longTitle -}}
2023-08-07 22:23:46 +00:00
{{- else if ( eq $mode "shortTitlePl" ) -}}
2023-07-01 03:16:59 +00:00
{{- with .longTitlePl -}}{{- . -}}{{- else -}}{{- .longTitle -}}s{{- end -}}
2023-08-07 22:23:46 +00:00
{{- end -}}
{{- if .lang }} [{{ .longTitleTrans }}]{{- end -}}
"
{{- with .lang }} lang="{{ . }}"{{- end -}}
>
2023-07-01 03:16:59 +00:00
{{- if ( eq $mode "shortTitle" ) -}}
{{- .shortTitle | safeHTML -}}
{{- else if ( eq $mode "shortTitlePl" ) -}}
{{- with .shortTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .shortTitle | safeHTML -}}s{{- end -}}
{{- end -}}
2023-08-07 22:23:46 +00:00
</abbr>{{- /**/ -}}
2024-07-23 08:08:36 +00:00
2023-08-07 22:23:46 +00:00
<!-- Long titles (e.g. 'foo bar baz') -->
{{- else if ( or ( eq $mode "longTitle" ) ( eq $mode "longTitlePl" ) ) -}}
2023-07-01 03:16:59 +00:00
{{- if ( eq $mode "longTitle" ) -}}
2023-08-07 22:23:46 +00:00
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- $.longTitleTrans | safeHTML -}}">{{- end -}}
2023-07-01 03:16:59 +00:00
{{- .longTitle | safeHTML -}}
2023-08-07 22:23:46 +00:00
{{- if .lang -}}</i>{{- end -}}
2023-07-01 03:16:59 +00:00
{{- else if ( eq $mode "longTitlePl" ) -}}
2023-08-07 22:23:46 +00:00
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- with .longTitleTransPl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitleTrans | safeHTML -}}s{{- end -}}">{{- end -}}
2023-07-01 03:16:59 +00:00
{{- with .longTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitle | safeHTML -}}s{{- end -}}
2023-08-07 22:23:46 +00:00
{{- if .lang -}}</i>{{- end -}}{{- /**/ -}}
2023-07-01 03:16:59 +00:00
{{- end -}}
2024-07-23 08:08:36 +00:00
2023-08-07 22:23:46 +00:00
<!-- Full titles (e.g. 'foo bar baz (FBB)') -->
2023-07-01 03:16:59 +00:00
{{- else if ( or ( eq $mode "fullTitle" ) ( eq $mode "fullTitlePl" ) ) -}}
{{- if ( eq $mode "fullTitle" ) -}}
2023-08-07 22:23:46 +00:00
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- .longTitleTrans | safeHTML -}}">{{- end -}}
{{- .longTitle | safeHTML -}}
{{- if .lang -}}</i>{{- end -}}
&nbsp;(<abbr{{- with .lang }} lang="{{ . }}"{{- end -}}>{{- .shortTitle | safeHTML -}}</abbr>)
2023-07-01 03:16:59 +00:00
{{- else if ( eq $mode "fullTitlePl" ) -}}
2023-08-07 22:23:46 +00:00
{{- if .lang -}}<i lang="{{- .lang -}}" title="{{- with .longTitleTransPl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitleTrans | safeHTML -}}s{{- end -}}">{{- end -}}
2023-07-01 03:16:59 +00:00
{{- with .longTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .longTitle | safeHTML -}}s{{- end -}}
2023-08-07 22:23:46 +00:00
{{- if .lang -}}</i>{{- end -}}
&nbsp;(<abbr{{- with .lang }} lang="{{ . }}"{{- end -}}>{{- with .shortTitlePl -}}{{- . | safeHTML -}}{{- else -}}{{- .shortTitle | safeHTML -}}s{{- end -}}</abbr>){{- /**/ -}}
2023-07-01 03:16:59 +00:00
{{- end -}}
{{- end -}}
{{- else -}}
{{- errorf "No definition found for abbreviation '%q'" $abbr -}}
{{- end -}}
2023-08-07 22:23:46 +00:00
{{- /**/ -}}