2023-07-27 16:14:55 +02:00
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
2023-11-21 00:53:33 +01:00
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'expand' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }}
2023-07-27 16:14:55 +02:00
{{- end }}
2022-06-22 20:32:18 +02:00
{{- $content := .content }}
{{- $title := .title | default (T "Expand-title") }}
2022-12-01 01:37:09 +01:00
{{- $title = trim $title " " }}
2024-09-01 13:57:50 +02:00
{{- $expanded := .expanded | default false }}
{{- if and (isset . "open") (or (ne (printf "%T" .open) "string") (ne (trim .open " " ) "")) }}
{{- warnf "%q: DEPRECATED parameter 'open' for shortcode 'expand' found, use 'expanded' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#630" $page.File.Filename }}
{{- $expanded = .open }}
{{- end }}
2022-06-22 20:32:18 +02:00
{{- if eq (printf "%T" $expanded) "string" }}
{{- $expanded = (eq $expanded "true") }}
{{- end }}
2023-07-27 16:14:55 +02:00
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }}
{{- with $page }}
2023-02-03 08:57:55 +01:00
< div class = "expand" >
2024-09-01 13:57:50 +02:00
< input type = "checkbox" id = "R-expand-{{ $id }}" aria-controls = "R-expandcontent-{{ $id }}" { { if $ expanded } } checked { { end } } >
< label class = "expand-label" for = "R-expand-{{ $id }}" >
< i class = "expander-icon fa-fw fas fa-chevron-down" > < / i >
< i class = "expander-icon fa-fw fas fa-chevron-right" > < / i > {{ $title | .RenderString }}
< / label >
< div id = "R-expandcontent-{{ $id }}" class = "expand-content" >
2024-09-01 20:37:58 +02:00
{{ if ne "< " (substr (strings.TrimLeft "\n\r\t " $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 }}