{{ $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 -}} {{ with .Get "outline" }}{{ $outline = partial "utilities/CastBool.html" . }}{{ 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 -}} {{ with .Get "cue" }}{{ $show = partial "utilities/CastBool.html" . }}{{ end -}} {{- $tab := default site.Params.main.externalLinks.tab -}} {{ with .Get "tab" }}{{ $show = partial "utilities/CastBool.html" . }}{{ end -}} {{- $spacing := default (not .Parent) -}} {{ with .Get "spacing" }}{{ $show = partial "utilities/CastBool.html" . }}{{ 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 }}