@register.simple_tag<EOL>def navactive(request, url, exact=<NUM_LIT:0>, use_resolver=<NUM_LIT:1>):
if use_resolver:<EOL><INDENT>try:<EOL><INDENT>if url == resolve(request.path).url_name:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif url == request.path:<EOL><INDENT>match = request.path<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>except Resolver404:<EOL><INDENT>match = request.path<EOL><DEDENT><DEDENT>else:<EOL><INDENT>match = request.path<EOL><DEDENT>if exact and url == match:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif not exact and url in request.path:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>return '<STR_LIT>'<EOL>
Returns ``active`` if the given URL is in the url path, otherwise ''.

Usage::

    {% load libs_tags %}
    ...
    <li class="{% navactive request "/news/" exact=1 %}">

:param request: A request instance.
:param url: A string representing a part of the URL that needs to exist
  in order for this method to return ``True``.
:param exact: If ``1`` then the parameter ``url`` must be equal to
  ``request.path``, otherwise the parameter ``url`` can just be a part of
  ``request.path``.
:use_resolver: If ``0`` we will not try to compare ``url`` with existing
  view names but we will only compare it with ``request.path``.