Open tzoiker opened 3 years ago
When will this get merged?
I'm using the following logic to validate if there are missing variables:
rendered_content = chevron.render(template, context)
# Find all variables in the template
variables = re.findall(r'{{\s*([\w.]+)\s*}}', template)
# Check if any variable resulted in an empty string
for var in variables:
var_rendered = chevron.render("{{" + var + "}}", context)
if var_rendered == "":
raise Exception(f"Variable '{var}' is missing from context or resulted in an empty string.")
@noahmorrison Any indication if this can/will get merged? We are in need of this behavior as well to be able to catch an exception when a there is a missing variables as that indicates there's a bug and we do not want to silently continue
Due to security issues we decided to migrate from jinja to mustache. Jinja supports error raising for missing variables, which is good for data validation purposes. Proposition:
error
flag to render (incompatible withkeep
,warn
);UndefinedError
only forvariable
,no escape
,partial
.