File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class BaseReportingConfig(BaseModel):
2828
2929 """
3030
31- UNTEMPLATED_FIELDS : ClassVar [set [str ]] = { "message" }
31+ UNTEMPLATED_FIELDS : ClassVar [set [str ]] = set ()
3232 """Fields that should not be templated."""
3333
3434 emit : Optional [str ] = None
Original file line number Diff line number Diff line change 1111from dve .core_engine .type_hints import JSONable , TemplateVariables
1212
1313
14+ class PreserveTemplateUndefined (jinja2 .Undefined ):
15+ """
16+ Preserve the original template in instances where the value cannot be populated. Whilst this
17+ may result in templates coming back in the FeedbackMessage object, it's more useful to know
18+ exactly what should have been populated rather than just returning blank values.
19+ """
20+ def __str__ (self ):
21+ return "{{" + self ._undefined_name + "}}"
22+
23+
1424class RuleTemplateError (ValueError ):
1525 """A rule template error."""
1626
@@ -21,7 +31,8 @@ def _raise_rule_templating_error(message: str) -> NoReturn:
2131
2232
2333T = TypeVar ("T" , bound = JSONable )
24- ENVIRONMENT = jinja2 .Environment (autoescape = False )
34+ # ENVIRONMENT = jinja2.Environment(autoescape=False)
35+ ENVIRONMENT = jinja2 .Environment (autoescape = False , undefined = PreserveTemplateUndefined )
2536ENVIRONMENT .globals ["repr" ] = repr
2637ENVIRONMENT .globals ["str" ] = str
2738ENVIRONMENT .globals ["raise" ] = _raise_rule_templating_error
You can’t perform that action at this time.
0 commit comments