import re


def active_nav(request, pattern):
    """Output 'is-active' class for html tags.

    Outputs `is-active` when the website slug (exclusive of /'s)
    matches the submitted pattern, for example:
      <a href="/contact" class="{% active_nav request "contact" %}">Contact</a>

    The above would render, if the user is on the `/contact/` page, as:
      <a href="/contact/" class="is-active">Contact</a>

    This is useful for basic pages that are unlikely to change. However,
    if you are using url looksup (`<a href="{% url 'feed' %}">`), then
    you should use the `reverse_active_nav` tag below.
    """
    if re.search('^/%s/' % (pattern,), request.path):
        return 'is-active'
    elif request.path == '/':
        return 'is-home'
    return ''