handle full value replacement in template

This commit is contained in:
iLLiCiTiT 2021-06-29 14:11:26 +02:00
parent 9cfd8af2bf
commit d91f470848

View file

@ -497,6 +497,7 @@ class SchemasHub:
.replace("{{", "__dbcb__")
.replace("}}", "__decb__")
)
full_replacement = False
for replacement_string in template_key_pattern.findall(template):
key = str(replacement_string[1:-1])
required_keys.add(key)
@ -509,11 +510,19 @@ class SchemasHub:
# Replace the value with value from templates data
# - with this is possible to set value with different type
template = value
full_replacement = True
else:
# Only replace the key in string
template = template.replace(replacement_string, value)
output = template.replace("__dbcb__", "{").replace("__decb__", "}")
if not full_replacement:
output = (
template
.replace("__dbcb__", "{")
.replace("__decb__", "}")
)
else:
output = template
else:
output = template