2022-06-22 20:32:18 +02:00
{{- $context := .context }}
{{- $content := .content }}
{{- $title := .title | default (T "Expand-title") }}
2022-12-01 01:37:09 +01:00
{{- $title = trim $title " " }}
2022-06-22 20:32:18 +02:00
{{- $expanded := .open | default false }}
{{- if eq (printf "%T" $expanded) "string" }}
{{- $expanded = (eq $expanded "true") }}
{{- end }}
2023-05-18 14:01:50 +02:00
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }}
2022-06-22 20:32:18 +02:00
{{- with $context }}
2023-02-03 08:57:55 +01:00
< div class = "expand" >
< input type = "checkbox" id = "expand-{{ $id }}" aria-controls = "expandcontent-{{ $id }}" { { if $ expanded } } checked { { end } } >
< label class = "expand-label" for = "expand-{{ $id }}" >
2022-06-22 20:32:18 +02:00
< i class = "fas fa-chevron-down" > < / i >
2023-02-09 01:02:06 +01:00
< i class = "fas fa-chevron-right" > < / i >
2023-06-03 13:14:15 +02:00
{{ $title | .RenderString }}
2023-02-03 08:57:55 +01:00
< / label >
< div id = "expandcontent-{{ $id }}" class = "expand-content" >
2023-06-05 00:24:14 +02:00
{{ if ne "< " (substr (strings.TrimLeft " " $content) 0 1) }}< p > {{ end }}<!-- we add a DOM element here if there is none to make collapsing marings work -->
2023-06-03 11:11:41 +02:00
{{ $content | safeHTML }}< / div > <!-- no line break allowed here because of awkward behavior of Hugo 110 or this theme when tag shortcode is called standalone outside of tags shortcode ? -->
2022-06-22 20:32:18 +02:00
< / div >
{{- end }}