Conditional statement for nav tag when no children
Have you tried something like:

&lt;li class="{{ page.getChildren()|length == 0 ? 'dropdown-item' : 'dropdown-submenu' }}"&gt;


If that doesn't work, I suspect you could use {% ifchildren %} in concert with a variable to set the style. In this case, we set the variable to a non-null value if there are children. Then we can use the null-coalescing operator to substitute 'dropdown-item' if there are no children. Like:

{% set listclass = null %}
{% ifchildren %}
    {% set listclass = 'dropdown-submenu' %}
{% endifchildren% }
&lt;li class="{{ listclass ?? 'dropdown-item' }}"&gt;