{{- $error := false -}} {{ $color := "primary" -}} {{ $icon := "" }} {{ $type := "" -}} {{ with .Get "type" }}{{ $type = . }}{{ end -}} {{ $supportedTypes := slice "danger" "info" -}} {{ if $type }} {{ if not (in $supportedTypes $type) -}} {{ errorf "Invalid value for param 'type': %s" .Position -}} {{ $error = true -}} {{ else }} {{ $color = $type }} {{ if eq $type "danger" }}{{ $icon = "fas triangle-exclamation" }}{{ else }}{{ $icon = "fa lightbulb" }}{{ end }} {{ end -}} {{ end -}} {{ 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 -}} {{ with .Get "icon" }}{{ $icon = . }}{{ end }} {{ with $icon }} {{ $icon = partial "assets/icon.html" (dict "icon" (printf "%s fa-2x fa-fw" .)) }} {{ end }} {{ $dismissibleParam := "false" -}} {{ $dismissible := false -}} {{ with .Get "dismissible" }}{{ $dismissibleParam = . }}{{ end -}} {{ $supportedFlags := slice "true" "false" -}} {{ if in $supportedFlags $dismissibleParam -}} {{ if eq $dismissibleParam "true" }}{{ $dismissible = true }}{{ end -}} {{ else -}} {{ errorf "Invalid value for param 'dismissible': %s" .Position -}} {{ $error = true -}} {{ end -}} {{- $class := .Get "class" | default "" -}} {{- if not $error -}} {{- end -}}