def active_path(context, pattern, css=None):
    """
    Highlight menu item based on path.
    
    Returns a css class if ``request.path`` is in given ``pattern``.
    
    :param pattern:
        Regex url pattern.

    :param css:
        Css class to be returned for highlighting. Return active if none set.

    """
    request = context['request']
    #pattern = "^" + pattern + "$"
    if re.search(pattern, request.path):
        return css if css else 'active'
    return ''