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:
Adrian Holovaty 2006-01-15 00:53:19 +00:00
parent 0b5043832b
commit 08f032f6b5
5 changed files with 22 additions and 7 deletions

View File

@ -3,7 +3,7 @@
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 */
a:link, a:visited { color: #5b80b2; text-decoration:none; }

View File

@ -257,6 +257,13 @@ class Parser(object):
self.unclosed_block_tag(parse_until)
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):
return VariableNode(filter_expression)
@ -363,8 +370,8 @@ def parser_factory(*args, **kwargs):
return DebugParser(*args, **kwargs)
else:
return Parser(*args, **kwargs)
class TokenParser:
"""
Subclass this and implement the top() method to parse a template line. When

View File

@ -286,8 +286,7 @@ def comment(parser, token):
"""
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``
"""
nodelist = parser.parse(('endcomment',))
parser.delete_first_token()
parser.skip_past('endcomment')
return CommentNode()
comment = register.tag(comment)

View File

@ -455,8 +455,12 @@ Let's jump back into the Python interactive shell by running
What's up?
>>> polls.get_object(question__startswith='What')
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)
What's up?
>>> polls.get_object(id__exact=2)
Traceback (most recent call last):
...

View File

@ -156,6 +156,11 @@ TEMPLATE_TESTS = {
'comment-tag01': ("{% comment %}this is hidden{% endcomment %}hello", {}, "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 #############################################################
#'cycleXX': ('', {}, ''),
'cycle01': ('{% cycle a, %}', {}, 'a'),
@ -440,7 +445,7 @@ def run_tests(verbosity=0, standalone=False):
failed_tests = []
tests = TEMPLATE_TESTS.items()
tests.sort()
# Turn TEMPLATE_DEBUG off, because tests assume that.
old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
for name, vals in tests:
@ -473,7 +478,7 @@ def run_tests(verbosity=0, standalone=False):
loader.template_source_loaders = old_template_loaders
deactivate()
settings.TEMPLATE_DEBUG = old_td
if failed_tests and not standalone:
msg = "Template tests %s failed." % failed_tests
if not verbosity: