{{ $currentPage := .Page }}
{{ range .Site.Menus.main }}
    {{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
        {{ if .HasChildren }}
            {{ range .Children }}
                {{ $submenu := "" }}
                {{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
                    {{ $submenu = " active"}}
                {{ end }}
                <a href="{{ .URL }}" class="{{ $submenu }}">
                    {{ print .Name | safeHTML }}
                </a>
            {{ end }}
        {{ end }}
    {{ end }}
{{ end }}