1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import re
from django import template
from django.core.urlresolvers import get_resolver
register = template.Library()
@register.simple_tag
def current(request, view):
possible_results = get_resolver(None).reverse_dict.getlist(view)
if len(possible_results) != 0 and re.match(possible_results[0][1], request.path[1:]):
return 'current'
return ''
|
More like this
- Active page class for selected menu items by kunitoki 7 months, 4 weeks ago
- template tag for highlighting currently active page by adunar 4 years, 7 months ago
- Active class for navigation link by cschand 3 years, 8 months ago
- Pagination Alphabetically compatible with paginator_class by vascop 1 year, 1 month ago
- Multi-level (tree-ish) navigation by jpic 4 years, 7 months ago
Comments