From: cmal Date: Tue, 17 Apr 2018 09:29:25 +0000 (+0200) Subject: Improve .Get docs X-Git-Tag: v0.40~19 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=74520d2cfd39bb4428182e26c57afa9df83ce7b5;p=brevno-suite%2Fhugo Improve .Get docs --- diff --git a/docs/content/functions/get.md b/docs/content/functions/get.md index 24ee9d70..f6d6a6e3 100644 --- a/docs/content/functions/get.md +++ b/docs/content/functions/get.md @@ -20,10 +20,13 @@ needsexample: true --- -`.Get` is specifically used when creating your own [shortcode template][sc]. - +`.Get` is specifically used when creating your own [shortcode template][sc], to access the [positional and named](/templates/shortcode-templates/#positional-vs-named-parameters) 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 a named parameter that does not exist, `.Get` returns an empty string instead of interrupting the build. The same goes with positional parameters in hugo version 0.40 and after. This allows you to chain `.Get` with `if`, `with`, `default` or `cond` to check for parameter existence. For example, you may now use: +``` +{{ $quality := default "100" (.Get 1) }} +``` [sc]: /templates/shortcode-templates/