{{ $error := false }} {{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "button" "args" .Params "group" "shortcode") }} {{ errorf "Invalid arguments: %s" .Position -}} {{ $error = true }} {{ end }} {{ $type := "button" -}} {{- $icon := .Get "icon" | default "" }} {{ $title := trim .Inner " \r\n" | .Page.RenderString -}} {{ if not (or $title $icon) -}} {{ errorf "Missing icon or inner element text: %s" .Position -}} {{ $error = true }} {{ end -}} {{ $state := .Get "state" | default "enabled" -}} {{ $size := .Get "size" | default "md" -}} {{ $color := .Get "color" | default "primary" -}} {{ $outline := false -}} {{ if isset .Params "outline" }}{{ $outline = partial "utilities/CastBool.html" (.Get "outline") }}{{ end -}} {{ $badge := .Get "badge" | default "" -}} {{ $label := or (.Get "label") (.Get "aria-label") | default "" -}} {{ $tooltip := .Get "tooltip" | default "" -}} {{ $collapse := .Get "collapse" | default "" -}} {{ $href := .Get "href" | default "" -}} {{ $relref := .Get "relref" | default "" -}} {{ $id := .Get "id" | default "" -}} {{ if $relref }} {{ $href = relref . $relref }} {{ end }} {{ $class := .Get "class" | default "" -}} {{ $placement := .Get "placement" | default "top" -}} {{- $toast := .Get "toast" | default "" -}} {{- $order := .Get "order" | default "last" -}} {{- $justify := .Get "justify" | default "center" -}} {{- $cue := site.Params.main.externalLinks.cue -}} {{ if isset .Params "cue" }}{{ $cue = partial "utilities/CastBool.html" (.Get "cue") }}{{ end -}} {{- $tab := default site.Params.main.externalLinks.tab -}} {{ if isset .Params "tab" }}{{ $tab = partial "utilities/CastBool.html" (.Get "tab") }}{{ end -}} {{- $spacing := default (not .Parent) -}} {{ if isset .Params "spacing" }}{{ $spacing = partial "utilities/CastBool.html" (.Get "spacing") }}{{ end -}} {{ if not $error }} {{- $output := partial "assets/button.html" (dict "type" $type "title" $title "size" $size "color" $color "outline" $outline "badge" $badge "label" $label "tooltip" $tooltip "collapse" $collapse "href" $href "id" $id "state" $state "class" $class "placement" $placement "icon" $icon "order" $order "justify" $justify "cue" $cue "tab" $tab "toast" $toast "spacing" $spacing) -}} {{ with .Get "wrapper" }} {{ $output = printf `
%s
` . $output }} {{ end }} {{- if .Parent -}} {{ $current := .Parent.Scratch.Get "inner" }} {{ if $current }} {{ .Parent.Scratch.Set "inner" (print $current $output) }} {{ else }} {{ .Parent.Scratch.Set "inner" $output }} {{ end }} {{- else -}} {{ $output | safeHTML }} {{- end -}} {{ end }}