Ticket #3543: url-tag-spaces.diff

File url-tag-spaces.diff, 2.9 KB (added by scott@…, 18 years ago)

Patch to defaulttags and test

  • django/template/defaulttags.py

     
    925925        for arg in bits[2].split(','):
    926926            if '=' in arg:
    927927                k, v = arg.split('=', 1)
     928                if ' ' in k:
     929                    raise TemplateSyntaxError, "'%s' must not have spaces in keyword arguments" % bits[0]
    928930                kwargs[k] = parser.compile_filter(v)
    929931            else:
    930932                args.append(parser.compile_filter(arg))
  • tests/regressiontests/templates/views.py

     
    88
    99def client_action(request, id, action):
    1010    pass
     11
     12def client_location(request, country, city):
     13    pass
  • tests/regressiontests/templates/tests.py

     
    651651            'url01' : ('{% url regressiontests.templates.views.client client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'),
    652652            'url02' : ('{% url regressiontests.templates.views.client_action client.id,action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),
    653653            'url03' : ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'),
     654            'url04' : ('{% url regressiontests.templates.views.client_location country="england",city="liverpool" %}', {}, '/url_tag/client/location/england/liverpool/'),
    654655
    655656            # Failures
    656             'url04' : ('{% url %}', {}, template.TemplateSyntaxError),
    657             'url05' : ('{% url no_such_view %}', {}, ''),
    658             'url06' : ('{% url regressiontests.templates.views.client no_such_param="value" %}', {}, ''),
     657            'url05' : ('{% url %}', {}, template.TemplateSyntaxError),
     658            'url06' : ('{% url no_such_view %}', {}, ''),
     659            'url07' : ('{% url regressiontests.templates.views.client no_such_param="value" %}', {}, ''),
     660            'url08' : ('{% url regressiontests.templates.views.client_location country="england", city="liverpool" %}', {}, template.TemplateSyntaxError),
    659661        }
    660662
    661663        # Register our custom template loader.
  • tests/regressiontests/templates/urls.py

     
    77    (r'^$', views.index),
    88    (r'^client/(\d+)/$', views.client),
    99    (r'^client/(\d+)/(?P<action>[^/]+)/$', views.client_action),
     10    (r'^client/location/(?P<country>[^/]+)/(?P<city>[^/]+)/$', views.client_location),
    1011)
Back to Top