diff options
author | cmal <paul@cmal.info> | 2018-04-17 11:29:25 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-04-17 15:39:33 +0200 |
commit | 74520d2cfd39bb4428182e26c57afa9df83ce7b5 (patch) | |
tree | 500c823555bb7e152d8a1f84e0104d50d1792607 /docs | |
parent | e2b277bba5935c0686cb83f132eae021ef2dc5e1 (diff) |
Improve .Get docs
Diffstat (limited to 'docs')
-rw-r--r-- | docs/content/functions/get.md | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/content/functions/get.md b/docs/content/functions/get.md index 24ee9d700..f6d6a6e31 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/ |