SES - allow single curly brace in template (#6208)

This commit is contained in:
Bert Blommers 2023-04-13 14:43:09 +00:00 committed by GitHub
parent 90d67db6ea
commit 4ef076341d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -10,7 +10,8 @@ def parse_template(template, template_data, tokenizer=None, until=None):
for char in tokenizer:
if until is not None and (char + tokenizer.peek(len(until) - 1)) == until:
return parsed
if char == "{":
if char == "{" and tokenizer.peek() == "{":
# Two braces next to each other indicate a variable/language construct such as for-each
tokenizer.skip_characters("{")
tokenizer.skip_white_space()
if tokenizer.peek() == "#":

View File

@ -24,3 +24,10 @@ def test_template_with_multiple_foreach():
"l2": [{"o1": "ob1", "o2": "ob2"}, {"o1": "oc1", "o2": "oc2"}],
}
parse_template(t, kwargs).should.equal(" - it1 - it2 and list 2 ob1 ob2 oc1 oc2 ")
def test_template_with_single_curly_brace():
t = "Dear {{name}} my {brace} is fine."
parse_template(t, template_data={"name": "John"}).should.equal(
"Dear John my {brace} is fine."
)