Files
hinode/layouts/shortcodes/toast.html
2023-08-31 13:34:23 +02:00

21 lines
881 B
HTML

<!--
Prepares a toast message. Use a trigger to display the message. The shortcode supports the following arguments:
"id" Optional id of the toast message, defaults to "toast-message-n" with sequence n.
"header": Optional header of the toast message. Uses the site title by default.
"class" Optional class attribute of the toast element.
-->
{{- $error := false -}}
{{- $id := printf "toast-message-%d" .Ordinal -}}
{{- with .Get "id" }}{{ $id = . }}{{ end -}}
{{ $header := .Get "header" | default "" -}}
{{ $message := trim .Inner " \r\n" | .Page.RenderString -}}
{{- $class := .Get "class" | default "" -}}
{{ if not $message -}}
{{ errorf "Missing inner element text: %s" .Position -}}
{{ else if not $error -}}
{{ partial "assets/toast.html" (dict "id" $id "header" $header "message" $message "class" $class) }}
{{ end -}}