hugo/docs/content/en/functions/Get.md
2023-10-20 09:43:56 +02:00

975 B

title description categories keywords menu function relatedFunctions
.Get Accesses positional and ordered parameters in shortcode declaration.
functions
docs
parent
functions
aliases returnType signatures
any
.Get INDEX
.Get KEY

.Get is specifically used when creating your own shortcode template, to access the positional and named parameters passed to it. When used with a numeric INDEX, it queries positional parameters (starting with 0). With a string KEY, it queries named parameters.

When accessing named or positional parameters that do not exist, .Get returns an empty string instead of interrupting the build. This allows you to chain .Get with if, with, default or cond to check for parameter existence. For example:

{{ $quality := default "100" (.Get 1) }}