{{ $error := false }} {{ $type := "link" -}} {{ $title := trim .Inner " \r\n" | plainify -}} {{ if not $title -}} {{ errorf "Missing inner element text: %s" .Position -}} {{ $error = true }} {{ end -}} {{ $color := "primary" -}} {{ with .Get "color" }}{{ $color = . }}{{ end -}} {{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" -}} {{ if not (in $supportedColors $color) -}} {{ errorf "Invalid value for param 'color': %s" .Position -}} {{ $error = true }} {{ end -}} {{ $tooltip := .Get "title" | default "" -}} {{ $href := .Get "href" | default "" -}} {{ if not $href -}} {{ errorf "Missing value for param 'href': %s" .Position -}} {{ $error = true }} {{ end -}} {{ $placement := "top" -}} {{ with .Get "placement" }}{{ $placement = . }}{{ end -}} {{ $supportedPlacements := slice "top" "bottom" "left" "right" -}} {{ if not (in $supportedPlacements $placement) -}} {{ errorf "Invalid value for param 'placement': %s" .Position -}} {{ $error = true }} {{ end -}} {{- $class := .Get "class" | default "" -}} {{ if not $error }}
{{- partial "assets/button.html" (dict "type" $type "title" $title "color" $color "tooltip" $tooltip "href" $href "placement" $placement "class" $class) -}}
{{ end }}