import re


def active(context, pattern, class_name='active'):
    """
    Return active when request path matches pattern
    """
    request = context.get('request')
    if request and re.search(pattern, request.path):
        return class_name
    return ''