I use the menu definitions to implement icon menus. On wide screen, there are four icons vertically stacked to the left, and four to the right. On small screen there is one horizontal set of all eight icons. I have three partials for that (iconsleft, iconsright and iconstop).
So I wanted in e.g. iconsleft something like:
{{ range .Site.Menus.main }}
{{ if eq .Target "left" }}
<div class="icon"> ... </div>
{{ end }}
{{ end }}
Interesting suggestion. Unfortunately, the identifier is also used for the icon image, folders etc.
Maybe I can abuse .Pre or .Post since I (currently) do not use these.
Ok. Glad you found another approach but I’m afraid that I don’t follow.
Within the menu context as posted in in post #3 you should be able to get the values. If that is not possible then something else is going on and we need to see the full project or you would need to share a sample project that reproduces what you encountered.
Do you mean that with the setup as posted in #1 and #3 it should be possible to use the value of the target property inside the partial?
In #2 you replied “Currently there is no support for custom menu variables.” so I understood this approach was not going to work. If I try I get the error can't evaluate field target :
Failed to render pages: render of "page" failed: execute of template failed: template: _default/single.html:8:10: executing "_default/single.html" at <partial "iconsleft.html" .>: error calling partial: "/bulk/tmp/quickstart/themes/september/layouts/partials/iconsleft.html:2:9": execute of template failed: template: partials/iconsleft.html:2:9: executing "partials/iconsleft.html" at <.target>: can't evaluate field target in type *navigation.MenuEntry