mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #5971 - Fixed inconsistent behaviour of the TokenParser when parsing filters that follow constant strings or variables. Thanks Dmitri Fedortchenko, Adam Vandenberg and Ramiro Morales.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12471 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -2,6 +2,55 @@
|
||||
Testing some internals of the template processing. These are *not* examples to be copied in user code.
|
||||
"""
|
||||
|
||||
token_parsing=r"""
|
||||
Tests for TokenParser behavior in the face of quoted strings with spaces.
|
||||
|
||||
>>> from django.template import TokenParser
|
||||
|
||||
|
||||
Test case 1: {% tag thevar|filter sometag %}
|
||||
|
||||
>>> p = TokenParser("tag thevar|filter sometag")
|
||||
>>> p.tagname
|
||||
'tag'
|
||||
>>> p.value()
|
||||
'thevar|filter'
|
||||
>>> p.more()
|
||||
True
|
||||
>>> p.tag()
|
||||
'sometag'
|
||||
>>> p.more()
|
||||
False
|
||||
|
||||
Test case 2: {% tag "a value"|filter sometag %}
|
||||
|
||||
>>> p = TokenParser('tag "a value"|filter sometag')
|
||||
>>> p.tagname
|
||||
'tag'
|
||||
>>> p.value()
|
||||
'"a value"|filter'
|
||||
>>> p.more()
|
||||
True
|
||||
>>> p.tag()
|
||||
'sometag'
|
||||
>>> p.more()
|
||||
False
|
||||
|
||||
Test case 3: {% tag 'a value'|filter sometag %}
|
||||
|
||||
>>> p = TokenParser("tag 'a value'|filter sometag")
|
||||
>>> p.tagname
|
||||
'tag'
|
||||
>>> p.value()
|
||||
"'a value'|filter"
|
||||
>>> p.more()
|
||||
True
|
||||
>>> p.tag()
|
||||
'sometag'
|
||||
>>> p.more()
|
||||
False
|
||||
"""
|
||||
|
||||
filter_parsing = r"""
|
||||
>>> from django.template import FilterExpression, Parser
|
||||
|
||||
|
||||
Reference in New Issue
Block a user