SES - allow single curly brace in template (#6208)
This commit is contained in:
parent
90d67db6ea
commit
4ef076341d
@ -10,7 +10,8 @@ def parse_template(template, template_data, tokenizer=None, until=None):
|
|||||||
for char in tokenizer:
|
for char in tokenizer:
|
||||||
if until is not None and (char + tokenizer.peek(len(until) - 1)) == until:
|
if until is not None and (char + tokenizer.peek(len(until) - 1)) == until:
|
||||||
return parsed
|
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_characters("{")
|
||||||
tokenizer.skip_white_space()
|
tokenizer.skip_white_space()
|
||||||
if tokenizer.peek() == "#":
|
if tokenizer.peek() == "#":
|
||||||
|
@ -24,3 +24,10 @@ def test_template_with_multiple_foreach():
|
|||||||
"l2": [{"o1": "ob1", "o2": "ob2"}, {"o1": "oc1", "o2": "oc2"}],
|
"l2": [{"o1": "ob1", "o2": "ob2"}, {"o1": "oc1", "o2": "oc2"}],
|
||||||
}
|
}
|
||||||
parse_template(t, kwargs).should.equal(" - it1 - it2 and list 2 ob1 ob2 oc1 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."
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user