diff --git a/apps/accounts/models/account.py b/apps/accounts/models/account.py index 99de5ddc0..0c6d507bc 100644 --- a/apps/accounts/models/account.py +++ b/apps/accounts/models/account.py @@ -128,13 +128,19 @@ class Account(AbsConnectivity, LabeledMixin, BaseAccount): if not isinstance(value, str): return value - value = value.replace('{{', '__TEMP_OPEN_BRACES__') \ - .replace('}}', '__TEMP_CLOSE_BRACES__') + def escape(v): + v = v.replace('{{', '__TEMP_OPEN_BRACES__') \ + .replace('}}', '__TEMP_CLOSE_BRACES__') - value = value.replace('__TEMP_OPEN_BRACES__', '{{ "{{" }}') \ - .replace('__TEMP_CLOSE_BRACES__', '{{ "}}" }}') + v = v.replace('__TEMP_OPEN_BRACES__', '{{ "{{" }}') \ + .replace('__TEMP_CLOSE_BRACES__', '{{ "}}" }}') - return value.replace('{%', '{{ "{%" }}').replace('%}', '{{ "%}" }}') + return v.replace('{%', '{{ "{%" }}').replace('%}', '{{ "%}" }}') + + if value.startswith('{{') and value.endswith('}}'): + return '{{' + escape(value[2:-2]) + '}}' + else: + return escape(value) def replace_history_model_with_mixin():