mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
added ability to keep '<>' without formatting content unchanged
This commit is contained in:
parent
c4fce5fea9
commit
8f5360d9d5
1 changed files with 20 additions and 6 deletions
|
|
@ -211,15 +211,28 @@ class StringTemplate(object):
|
|||
if counted_symb > -1:
|
||||
parts = tmp_parts.pop(counted_symb)
|
||||
counted_symb -= 1
|
||||
# If part contains only single string keep value
|
||||
# unchanged
|
||||
if parts:
|
||||
# Remove optional start char
|
||||
parts.pop(0)
|
||||
if counted_symb < 0:
|
||||
out_parts = new_parts
|
||||
else:
|
||||
out_parts = tmp_parts[counted_symb]
|
||||
# Store temp parts
|
||||
out_parts.append(OptionalPart(parts))
|
||||
|
||||
if not parts:
|
||||
value = "<>"
|
||||
elif (
|
||||
len(parts) == 1
|
||||
and isinstance(parts[0], six.string_types)
|
||||
):
|
||||
value = "<{}>".format(parts[0])
|
||||
else:
|
||||
value = OptionalPart(parts)
|
||||
|
||||
if counted_symb < 0:
|
||||
out_parts = new_parts
|
||||
else:
|
||||
out_parts = tmp_parts[counted_symb]
|
||||
# Store value
|
||||
out_parts.append(value)
|
||||
continue
|
||||
|
||||
if counted_symb < 0:
|
||||
|
|
@ -793,6 +806,7 @@ class OptionalPart:
|
|||
parts(list): Parts of template. Can contain 'str', 'OptionalPart' or
|
||||
'FormattingPart'.
|
||||
"""
|
||||
|
||||
def __init__(self, parts):
|
||||
self._parts = parts
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue