Sign in

Question about submenu

  • This topic has 1 reply, 2 voices, and was last updated 2 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #3162

    I am checking the menu partial, what is the return value of {{#unless level}} ? I cannot find “level” in the doc.

    <code class=" language-handlebars"><span class="token handlebars language-handlebars"><span class="token delimiter punctuation">{{</span><span class="token block keyword">#unless</span> <span class="token variable">level</span><span class="token delimiter punctuation">}}</span></span>

    {{#unless}} is the opposite of {{#if}}. So if we want to exclude <nav> element from the submenus (it wouldn’t be semantic) we should use the {{#unless level}} helper for that:

    {{#unless level}}
        <ul{{#if level}} class="submenu submenu-level-{{level}}"{{else}} class="menu menu-level-1"{{/if}}>
            {{#each items}}
                {{#if link}}
                <a href="{{menuUrl}}"{{#if title}} title="{{title}}"{{/if}}{{#if target}} target="{{target}}"{{/if}}{{#if rel}} rel="{{rel}}"{{/if}}>{{label}}</a>
                <span{{#if title}} title="{{title}}"{{/if}}>{{label}}</span>
                {{#if items}}
                    {{> menu}}
    {{#unless level}}

    in short: if your menu generates submenus (more levels) the nav container will be used only one.

    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.