1. Michael P. Jung
  2. django-ifnav-templatetag

Overview

HTTPS SSH

ifnav-Tag for Django Templates

The ifnav-Tag is used to match the current request path against a regular expression.

Example:

{% load ifnav %} <ul>

<li{% ifnav "^/foo/" %} class="selected"{% endifnav %}
<a href="/foo/">Foo</a></li>
<li{% ifnav "^/bar/" %} class="selected"{% endifnav %}
<a href="/bar/">Bar</a></li>

</ul>

This tag is meant for rather simple and static navigations.

In order to use this tag you have to enable the request context processor, which comes with django, but is disabled by default:

http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request

Alternatively you can also set the request object in the template context directly.