правильно сделан таг ???

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def do_ifequal(parser, token, negate):
bits = list(token.split_contents())
if len(bits) != 3:
raise TemplateSyntaxError, "%r takes two arguments" % bits[0]
end_tag = 'end' + bits[0]
nodelist_true = parser.parse(('elif','else', end_tag))
token = parser.next_token()
if token.contents == 'elif':
nodelist_false = parser.parse(('elif','else',end_tag))
parser.delete_first_token()
elif token.contents == 'else':
nodelist_false = parser.parse((end_tag,))
parser.delete_first_token()
else:
nodelist_false = NodeList()
return template.IfEqualNode(bits[1], bits[2], nodelist_true, nodelist_false, negate)
def ifequal(parser, token):
return do_ifequal(parser, token, False)
register.tag('ifequal', ifequal)