mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-13 21:13:21 +00:00
21 lines
881 B
HTML
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 -}}
|