How do I go about using len to count the total number of child menus (if there are any)?
Test code:
{{- range .Site.Menus.main }}
{{ if .HasChildren }}
{{ $children := len .Children }}
{{ print $children }}
<li>
....
</li>
{{ end }}
{{ end }}
The above prints the individual number of child menus each parent menu has. However, I want to count the total number of child menus for all parent menus.
e.g. If parent menu A has 7 child menus and parent menu B has 2 child menus, I’d like to print a count of 9.
Is this possible? Should it be done outside the range statement?