Bläddra i källkod

Fix: illegal variable name in Jinja2 (#8348)

### What problem does this PR solve?

Fix illegal variable name in Jinja2. #8316.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.19.1
Yongteng Lei 4 månader sedan
förälder
incheckning
3671d20e43
Inget konto är kopplat till bidragsgivarens mejladress
1 ändrade filer med 11 tillägg och 0 borttagningar
  1. 11
    0
      agent/component/template.py

+ 11
- 0
agent/component/template.py Visa fil

@@ -78,6 +78,11 @@ class Template(ComponentBase):
if p["key"] == key:
value = p.get("value", "")
self.make_kwargs(para, kwargs, value)

origin_pattern = "{begin@" + key + "}"
new_pattern = "begin_" + key
content = content.replace(origin_pattern, new_pattern)
kwargs[new_pattern] = kwargs.pop(origin_pattern, "")
break
else:
assert False, f"Can't find parameter '{key}' for {cpn_id}"
@@ -92,6 +97,12 @@ class Template(ComponentBase):
else:
hist = ""
self.make_kwargs(para, kwargs, hist)

if ":" in component_id:
origin_pattern = "{" + component_id + "}"
new_pattern = component_id.replace(":", "_")
content = content.replace(origin_pattern, new_pattern)
kwargs[new_pattern] = kwargs.pop(component_id, "")
continue

_, out = cpn.output(allow_partial=False)

Laddar…
Avbryt
Spara