# -*- coding: utf-8 -*-

import logging

from django.conf import settings
from django.core.urlresolvers import reverse as django_reverse, NoReverseMatch
from django.contrib.staticfiles.storage import staticfiles_storage

JINJA2_MUTE_URLRESOLVE_EXCEPTIONS = getattr(settings, "JINJA2_MUTE_URLRESOLVE_EXCEPTIONS", False)
logger = logging.getLogger(__name__)


def url(name, *args, **kwargs):
    """
    Shortcut filter for reverse url on templates. Is a alternative to
    django {% url %} tag, but more simple.

    Usage example:
        {{ url('web:timeline', userid=2) }}

    This is a equivalent to django:
        {% url 'web:timeline' userid=2 %}

    """
    try:
        return django_reverse(name, args=args, kwargs=kwargs)
    except NoReverseMatch as exc:
        logger.error('Error: %s', exc)
        if not JINJA2_MUTE_URLRESOLVE_EXCEPTIONS:
            raise
        return ''


def static(path):
    return staticfiles_storage.url(path)

# -*- coding: utf-8 -*-

import logging

from django.conf import settings
from django.core.urlresolvers import reverse as django_reverse, NoReverseMatch
from django.contrib.staticfiles.storage import staticfiles_storage

JINJA2_MUTE_URLRESOLVE_EXCEPTIONS = getattr(settings, "JINJA2_MUTE_URLRESOLVE_EXCEPTIONS", False)
logger = logging.getLogger(__name__)


def url(view_name, *args, **kwargs):
    """
    Shortcut filter for reverse url on templates. Is a alternative to
    django {% url %} tag, but more simple.

    Usage example:
        {{ url('web:timeline', userid=2) }}

    This is a equivalent to django:
        {% url 'web:timeline' userid=2 %}

    """
    try:
        return django_reverse(view_name, args=args, kwargs=kwargs)
    except NoReverseMatch as exc:
        logger.error('Error: %s', exc)
        if not JINJA2_MUTE_URLRESOLVE_EXCEPTIONS:
            raise
        return ''


def static(path):
    return staticfiles_storage.url(path)

Change parameter name so it does not conflict with an url parameter called "name".
builtins/url: Change parameter name so it does not conflict with an url parameter called "name".

This reflects the same name used in https://github.com/coffin/coffin/blob/master/coffin/template/defaultfilters.py, but it's probably as bad as a solution, because now you cannot use url() with a "view_name" url parameter. Maybe a better way to implement it would be to pop the first *args element (that'd raise if no arg is provided) and use it as the view name.