Files
hinode/layouts/shortcodes/collapse.html
2024-01-01 12:32:39 +01:00

28 lines
897 B
HTML

<!--
Copyright © 2024 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "collapse" "args" .Params) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ $id := .Get "id" -}}
{{ $class := .Get "class" | default "" }}
{{- $body := trim .Inner " \r\n" -}}
{{ if not $body -}}
{{ errorf "Missing inner element text: %s" .Position -}}
{{ end -}}
<!-- Main code -->
{{ if not $error }}
<div class="collapse my-4" id="{{ $id }}">
<div{{ with $class }} class="{{ . }}"{{ end }}>{{ $body | .Page.RenderString }}</div>
</div>
{{ end }}