{{navigation}} not working in partials

#1

I create ./partials/navigation.hbs file and add this code:

<ul class="site-nav"> 
 {{#foreach navigation}} 
  <li class="nav-{{slug}}{{#if current}} nav-current{{/if}}"> 
   <a href="{{url absolute="true"}}">{{label}}</a> 
  </li> 
 {{/foreach}}
</ul>

Then call it inside index.hbs whith this helper {{> "navigation"}}
But it shows nothing.
https://docs.ghost.org/api/handlebars-themes/helpers/navigation/#changing-the-template

It works correctly when using {{navigation}}
https://docs.ghost.org/api/handlebars-themes/helpers/navigation/#description

Why this happening? Is this bug?

#2

That’s expected, the {{navigation}} helper is what sets up the context for ./partials/navigation.hbs to work.

By creating the partial file you are overriding the default template that {{navigation}} uses but you still need to use it as {{navigation}} inside index.hbs (or other file) rather than {{> "navigation"}}

#3

But when I add custom class it doesn’t work. Like this:
{{#foreach navigation}}
<li class="customclass nav-{{slug}}{{#if current}} nav-current{{/if}}">
<a href="{{url absolute="true"}}">{{label}}</a>
</li>
{{/foreach}}
Cannot add custom class.