Skip to content

Instantly share code, notes, and snippets.

@dharma017
Forked from peksi/menu.twig
Created December 12, 2016 07:06
Show Gist options
  • Save dharma017/534a399a6a6f5548196742b4a2e372bc to your computer and use it in GitHub Desktop.
Save dharma017/534a399a6a6f5548196742b4a2e372bc to your computer and use it in GitHub Desktop.
Bootstrap dropdown navbar implementation for Wordpress Timber plugin.
{# Bootstrap dropdown navbar for Wordpress #}
<ul class="nav navbar-nav">
{% for item in menu %}
{% if (item.get_children) %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{item.title}} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for subitem in item.get_children %}
<li><a href="{{subitem.get_link}}">
<span data-letters="{{subitem.title}}">{{subitem.title}}</span>
</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="{{item.classes | join(' ')}}">
<a href="{{item.get_link}}">
<span data-letters="{{item.title}}">{{item.title}}</span>
</a>
{% include "menu.twig" with {'menu': item.get_children} %}
</li>
{% endif %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment