def feature(parser, token):
bits = token.split_contents()
if len(bits) < 2:
raise template.TemplateSyntaxError("%r tag requires an argument" % token.contents.split()[0])
name = bits[1]
params = bits[2:]
nodelist_true = parser.parse(('else', 'endfeature'))
token = parser.next_token()
if token.contents == 'else':
nodelist_false = parser.parse(('endfeature',))
parser.delete_first_token()
else:
nodelist_false = template.NodeList()
return FeatureNode(nodelist_true, nodelist_false, name, params)
评论列表
文章目录