Skip to content

Instantly share code, notes, and snippets.

@dubbs
Created January 24, 2013 22:16
Show Gist options
  • Save dubbs/4628594 to your computer and use it in GitHub Desktop.
Save dubbs/4628594 to your computer and use it in GitHub Desktop.
import re
def in_active_path(nav_slug, page_slug):
return re.match(nav_slug, page_slug)
{% block primary %}
<ul>
{% for slug, title, children in NAVIGATION %}
{% if slug|in_active_path(page.slug) %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="{{SITEURL}}/{{slug}}/">{{title}}</a>
</li>
{% endfor %}
</ul>
{% endblock %}
{% block secondary %}
<ul id="nav-secondary" class="two columns">
{%- for slug, title, children in NAVIGATION recursive %}
{% set active = slug|in_active_path(page.slug) %}
{% if active %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="{{SITEURL}}/{{slug}}/">{{ title }}</a>
{%- if children and active -%}
<ul>{{ loop(children) }}</ul>
{%- endif %}
</li>
{%- endfor %}
</ul>
{% endblock %}
import os
import sys
from pelican.plugins import assets
sys.path.append(os.path.dirname(__file__))
from filters import in_active_path
JINJA_FILTERS = {
'in_active_path': in_active_path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment