From 480c353edb5cf7ad52f3a54a283c7ecbda90e2f6 Mon Sep 17 00:00:00 2001 From: Ihor Aleksandrychiev Date: Tue, 7 Oct 2025 14:04:42 +0300 Subject: [PATCH] Added Params shortcode Params shortcode provides access to global params from the content files. Ticket: ENT-13254 Signed-off-by: Ihor Aleksandrychiev --- layouts/shortcodes/params.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 layouts/shortcodes/params.html diff --git a/layouts/shortcodes/params.html b/layouts/shortcodes/params.html new file mode 100644 index 0000000..1cbee1d --- /dev/null +++ b/layouts/shortcodes/params.html @@ -0,0 +1,17 @@ +{{/* This shortcode provides access to global site params */}} +{{- $paramString := .Get 0 -}} +{{/* split param string into keys by . to get access to nestend parameters value */}} +{{- $keys := split $paramString "." -}} +{{- $value := .Site.Params -}} +{{- $exists := true -}} +{{- range $keys -}} + {{- if $value -}} + {{- $value = index $value . -}} + {{- else -}} + {{- $exists = false -}} + {{- end -}} +{{- end -}} +{{- if not $exists -}} + {{- errorf "Config shortcode: key '%s' does not exist in site config." $paramString -}} +{{- end -}} +{{- $value -}}