Fix using variables in the middle of template strings

This commit is contained in:
Tulir Asokan 2020-08-27 15:03:32 +03:00
parent 45ee715dc3
commit 8353e43e30

View file

@ -53,11 +53,11 @@ class Template:
self._map_variable_locations((*path, i), v) self._map_variable_locations((*path, i), v)
elif isinstance(data, dict): elif isinstance(data, dict):
for k, v in data.items(): for k, v in data.items():
if variable_regex.match(k): if variable_regex.search(k):
self._variable_locations.append((*path, Key(k))) self._variable_locations.append((*path, Key(k)))
self._map_variable_locations((*path, k), v) self._map_variable_locations((*path, k), v)
elif isinstance(data, str): elif isinstance(data, str):
if variable_regex.match(data): if variable_regex.search(data):
self._variable_locations.append(path) self._variable_locations.append(path)
@classmethod @classmethod