|
|
@ -76,7 +76,7 @@ def split_args(args):
|
|
|
|
do_decode = True
|
|
|
|
do_decode = True
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
do_decode = False
|
|
|
|
do_decode = False
|
|
|
|
tokens = args.split(' ')
|
|
|
|
items = args.split(' ')
|
|
|
|
|
|
|
|
|
|
|
|
# iterate over the tokens, and reassemble any that may have been
|
|
|
|
# iterate over the tokens, and reassemble any that may have been
|
|
|
|
# split on a space inside a jinja2 block.
|
|
|
|
# split on a space inside a jinja2 block.
|
|
|
@ -92,9 +92,23 @@ def split_args(args):
|
|
|
|
block_depth = 0 # used to count nested jinja2 {% %} blocks
|
|
|
|
block_depth = 0 # used to count nested jinja2 {% %} blocks
|
|
|
|
comment_depth = 0 # used to count nested jinja2 {# #} blocks
|
|
|
|
comment_depth = 0 # used to count nested jinja2 {# #} blocks
|
|
|
|
|
|
|
|
|
|
|
|
# now we loop over each split token, coalescing tokens if the white space
|
|
|
|
# now we loop over each split chunk, coalescing tokens if the white space
|
|
|
|
# split occurred within quotes or a jinja2 block of some kind
|
|
|
|
# split occurred within quotes or a jinja2 block of some kind
|
|
|
|
for token in tokens:
|
|
|
|
for item in items:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# we split on spaces and newlines separately, so that we
|
|
|
|
|
|
|
|
# can tell which character we split on for reassembly
|
|
|
|
|
|
|
|
# inside quotation characters
|
|
|
|
|
|
|
|
tokens = item.split('\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for idx,token in enumerate(tokens):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if we're at the end of the enumeration, the character separator
|
|
|
|
|
|
|
|
# used when reassembling quoted bits should be a space, otherwise
|
|
|
|
|
|
|
|
# it will be a newline character
|
|
|
|
|
|
|
|
spacer = ' '
|
|
|
|
|
|
|
|
if idx > 0:
|
|
|
|
|
|
|
|
spacer = '\n'
|
|
|
|
|
|
|
|
|
|
|
|
# store the previous quoting state for checking later
|
|
|
|
# store the previous quoting state for checking later
|
|
|
|
was_inside_quotes = inside_quotes
|
|
|
|
was_inside_quotes = inside_quotes
|
|
|
@ -115,7 +129,7 @@ def split_args(args):
|
|
|
|
params.append(token)
|
|
|
|
params.append(token)
|
|
|
|
appended = True
|
|
|
|
appended = True
|
|
|
|
elif print_depth or block_depth or comment_depth or inside_quotes or was_inside_quotes:
|
|
|
|
elif print_depth or block_depth or comment_depth or inside_quotes or was_inside_quotes:
|
|
|
|
params[-1] = "%s %s" % (params[-1], token)
|
|
|
|
params[-1] = "%s%s%s" % (params[-1], spacer, token)
|
|
|
|
appended = True
|
|
|
|
appended = True
|
|
|
|
|
|
|
|
|
|
|
|
# if the number of paired block tags is not the same, the depth has changed, so we calculate that here
|
|
|
|
# if the number of paired block tags is not the same, the depth has changed, so we calculate that here
|
|
|
|