Check if empty front matter array

And with Hugo latest goodies:

  • variable overwrite
  • return statement in partial which makes this test more maintainable/reusuable
{{/* layouts/partials/func/HasValues.html */}}

{{ $return := false }}
{{ with . }}
  {{ range $key, $value := . }}
    {{ with $value }}
      {{ $return = true }}
    {{ end }}
   {{ end }}
{{ end }}

{{ return $return }}
{{/* layouts/_default/single.html */}}


 {{ with partial "func/HasValues" .Params.product }}
    🎉
 {{ end }}

7 Likes