Add dict to menu range?

Hi all,
I wanted to know how I can go about added a dict to a menu range, I wanted to add a class to the following when using {{ partial "menu/site" (dict "class" "foobar" ) }}

<ul>
  {{ range .Site.Menus.site }}
  <li><a href="{{ .URL }}" class="{{ .class }}">{{ .Title }}</a></li>
  {{ end }}
</ul>

Thank you.

layouts/partials/menu/site.html

<ul>
  {{ range site.Menus.site }}
    <li><a href="{{ .URL }}" class="{{ $.class }}">{{ .Name }}</a></li>
  {{ end }}
</ul>

Call it like this:

{{ partial "menu/site.html" (dict "class" "foobar") }}
1 Like

Thank you kindly this worked!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.