Allow non-string variables
This commit is contained in:
parent
47e1d5d7ec
commit
3900b04dba
1 changed files with 3 additions and 0 deletions
|
@ -111,6 +111,9 @@ class Template:
|
||||||
def _replace_variables(tpl: str, variables: Dict[str, Any]) -> str:
|
def _replace_variables(tpl: str, variables: Dict[str, Any]) -> str:
|
||||||
for match in variable_regex.finditer(tpl):
|
for match in variable_regex.finditer(tpl):
|
||||||
val = variables[match.group(1)]
|
val = variables[match.group(1)]
|
||||||
|
if match.start() == 0 and match.end() == len(tpl):
|
||||||
|
# Whole field is a single variable, just return the value to allow non-string types.
|
||||||
|
return val
|
||||||
tpl = tpl[:match.start()] + val + tpl[match.end():]
|
tpl = tpl[:match.start()] + val + tpl[match.end():]
|
||||||
return tpl
|
return tpl
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue