magic-removal: Merged to [1964]
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1965 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0b5043832b
commit
08f032f6b5
|
@ -3,7 +3,7 @@
|
||||||
by Wilson Miner (wminer@ljworld.com). Copyright 2004-2005 Lawrence Journal-World
|
by Wilson Miner (wminer@ljworld.com). Copyright 2004-2005 Lawrence Journal-World
|
||||||
*/
|
*/
|
||||||
|
|
||||||
body { margin:0; padding:0; font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif; color:#333; }
|
body { margin:0; padding:0; font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif; color:#333; background:#fff; }
|
||||||
|
|
||||||
/* LINKS */
|
/* LINKS */
|
||||||
a:link, a:visited { color: #5b80b2; text-decoration:none; }
|
a:link, a:visited { color: #5b80b2; text-decoration:none; }
|
||||||
|
|
|
@ -257,6 +257,13 @@ class Parser(object):
|
||||||
self.unclosed_block_tag(parse_until)
|
self.unclosed_block_tag(parse_until)
|
||||||
return nodelist
|
return nodelist
|
||||||
|
|
||||||
|
def skip_past(self, endtag):
|
||||||
|
while self.tokens:
|
||||||
|
token = self.next_token()
|
||||||
|
if token.token_type == TOKEN_BLOCK and token.contents == endtag:
|
||||||
|
return
|
||||||
|
self.unclosed_block_tag([endtag])
|
||||||
|
|
||||||
def create_variable_node(self, filter_expression):
|
def create_variable_node(self, filter_expression):
|
||||||
return VariableNode(filter_expression)
|
return VariableNode(filter_expression)
|
||||||
|
|
||||||
|
@ -363,8 +370,8 @@ def parser_factory(*args, **kwargs):
|
||||||
return DebugParser(*args, **kwargs)
|
return DebugParser(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
return Parser(*args, **kwargs)
|
return Parser(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class TokenParser:
|
class TokenParser:
|
||||||
"""
|
"""
|
||||||
Subclass this and implement the top() method to parse a template line. When
|
Subclass this and implement the top() method to parse a template line. When
|
||||||
|
|
|
@ -286,8 +286,7 @@ def comment(parser, token):
|
||||||
"""
|
"""
|
||||||
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``
|
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``
|
||||||
"""
|
"""
|
||||||
nodelist = parser.parse(('endcomment',))
|
parser.skip_past('endcomment')
|
||||||
parser.delete_first_token()
|
|
||||||
return CommentNode()
|
return CommentNode()
|
||||||
comment = register.tag(comment)
|
comment = register.tag(comment)
|
||||||
|
|
||||||
|
|
|
@ -455,8 +455,12 @@ Let's jump back into the Python interactive shell by running
|
||||||
What's up?
|
What's up?
|
||||||
>>> polls.get_object(question__startswith='What')
|
>>> polls.get_object(question__startswith='What')
|
||||||
What's up?
|
What's up?
|
||||||
|
|
||||||
|
# Get the poll whose year is 2005. Of course, if you're going through this
|
||||||
|
# tutorial in another year, change as appropriate.
|
||||||
>>> polls.get_object(pub_date__year=2005)
|
>>> polls.get_object(pub_date__year=2005)
|
||||||
What's up?
|
What's up?
|
||||||
|
|
||||||
>>> polls.get_object(id__exact=2)
|
>>> polls.get_object(id__exact=2)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
|
|
|
@ -156,6 +156,11 @@ TEMPLATE_TESTS = {
|
||||||
'comment-tag01': ("{% comment %}this is hidden{% endcomment %}hello", {}, "hello"),
|
'comment-tag01': ("{% comment %}this is hidden{% endcomment %}hello", {}, "hello"),
|
||||||
'comment-tag02': ("{% comment %}this is hidden{% endcomment %}hello{% comment %}foo{% endcomment %}", {}, "hello"),
|
'comment-tag02': ("{% comment %}this is hidden{% endcomment %}hello{% comment %}foo{% endcomment %}", {}, "hello"),
|
||||||
|
|
||||||
|
# Comment tag can contain invalid stuff.
|
||||||
|
'comment-tag03': ("foo{% comment %} {% if %} {% endcomment %}", {}, "foo"),
|
||||||
|
'comment-tag04': ("foo{% comment %} {% endblock %} {% endcomment %}", {}, "foo"),
|
||||||
|
'comment-tag05': ("foo{% comment %} {% somerandomtag %} {% endcomment %}", {}, "foo"),
|
||||||
|
|
||||||
### CYCLE TAG #############################################################
|
### CYCLE TAG #############################################################
|
||||||
#'cycleXX': ('', {}, ''),
|
#'cycleXX': ('', {}, ''),
|
||||||
'cycle01': ('{% cycle a, %}', {}, 'a'),
|
'cycle01': ('{% cycle a, %}', {}, 'a'),
|
||||||
|
@ -440,7 +445,7 @@ def run_tests(verbosity=0, standalone=False):
|
||||||
failed_tests = []
|
failed_tests = []
|
||||||
tests = TEMPLATE_TESTS.items()
|
tests = TEMPLATE_TESTS.items()
|
||||||
tests.sort()
|
tests.sort()
|
||||||
|
|
||||||
# Turn TEMPLATE_DEBUG off, because tests assume that.
|
# Turn TEMPLATE_DEBUG off, because tests assume that.
|
||||||
old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
|
old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
|
||||||
for name, vals in tests:
|
for name, vals in tests:
|
||||||
|
@ -473,7 +478,7 @@ def run_tests(verbosity=0, standalone=False):
|
||||||
loader.template_source_loaders = old_template_loaders
|
loader.template_source_loaders = old_template_loaders
|
||||||
deactivate()
|
deactivate()
|
||||||
settings.TEMPLATE_DEBUG = old_td
|
settings.TEMPLATE_DEBUG = old_td
|
||||||
|
|
||||||
if failed_tests and not standalone:
|
if failed_tests and not standalone:
|
||||||
msg = "Template tests %s failed." % failed_tests
|
msg = "Template tests %s failed." % failed_tests
|
||||||
if not verbosity:
|
if not verbosity:
|
||||||
|
|
Loading…
Reference in New Issue