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

29 lines
964 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" "button-group" "args" .Params) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ $label := .Get "label" | default (.Get "aria-label") }}
{{ $inner := .Scratch.Get "inner" }}
{{ $input := trim .Inner " \r\n" }}
{{ if $input }}
{{ $input = replace $input "\n" "\n " }}
{{ warnf "Unexpected inner content: %s\r\n %s" .Position $input }}
{{ end }}
<!-- Main code -->
{{ if not $error }}
<div class="btn-group" role="group" {{ with $label }}aria-label="{{ . }}"{{ end }}>
{{ $inner | safeHTML }}
</div>
{{ end }}