def smart_if(parser, token):
if_elifs = []
if_spelling = 'if'
class Enders(list):
def __contains__(self, val):
return val.startswith('elif') or val in ['else', 'endif']
enders = Enders()
while True:
contents = token.split_contents()
command = contents[0]
bits = contents[1:]
if command == if_spelling:
var = TemplateIfParser(parser, bits).parse()
nodelist = parser.parse(enders)
next_token = parser.next_token()
if_elifs.append((var, nodelist, token))
if_spelling = 'elif'
token = next_token
elif token.contents == 'else':
nodelist_false = parser.parse(('endif',))
parser.delete_first_token()
break
elif token.contents == 'endif':
nodelist_false = None
break
while len(if_elifs) > 1:
var, nodelist_true, token = if_elifs.pop()
false_node = SmartIfNode(var, nodelist_true, nodelist_false)
nodelist_false = parser.create_nodelist()
parser.extend_nodelist(nodelist_false, false_node, token)
var, nodelist_true, token = if_elifs[0]
return SmartIfNode(var, nodelist_true, nodelist_false)
Comments
This is a great inspiring article.I am pretty much pleased with your good work.You put really helpful information. Keep it up.
agen ibcbet, Judi, Modifikasi, Bokep Streaming, Casino, Poker
#
I am very happy to read this article, thanks for giving us go through info.Fantastic nice. I appreciate this post. Jasa seo, Ghantoby
#
I must say This post contains very useful information which help me a lot, Resources like the one you mentioned here will be very useful. Jasa seo
#