Can one use array for isset? And why `if` vs. `isset`

To specifically check that a param has been set to a falsy value.

Here we call the same shortcode three times. Note that the param is unquoted (boolean).

{{< foo >}}
{{< foo x=true >}}
{{< foo x=false >}}

If we want to set the default value to true:

{{/* Set default */}}
{{ $x := true }}

{{/* Get param */}}
{{ if .Params }}
  {{ if isset .Params "x" }}
    {{ $x = .Get "x" }}
  {{ end }}
{{ end }}

{{/* Display param */}}
{{ $x }}
2 Likes