CCrypto VPN public website https://vpn.ccrypto.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 lines
447 B

  1. import re
  2. from django import template
  3. from django.core.urlresolvers import reverse, NoReverseMatch
  4. register = template.Library()
  5. @register.simple_tag(takes_context=True)
  6. def active(context, pattern_or_urlname):
  7. try:
  8. pattern = '^' + reverse(pattern_or_urlname)
  9. except NoReverseMatch:
  10. pattern = pattern_or_urlname
  11. path = context['request'].path
  12. if re.search(pattern, path):
  13. return 'active'
  14. return ''