Skip to content

Instantly share code, notes, and snippets.

@mnazim
mnazim / active_tag.py
Created July 9, 2011 14:59
(Django) A simple template tag to add an 'active' class to anchor tags
from django import template
from django.core.urlresolvers import reverse
register = template.Library()
@register.simple_tag
def add_active(request, name, by_path=False):
""" Return the string 'active' current request.path is same as name
Keyword aruguments: