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 ''