Created
January 24, 2013 22:16
-
-
Save dubbs/4628594 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def in_active_path(nav_slug, page_slug): | |
return re.match(nav_slug, page_slug) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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