mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Find template errors hidden by conditionals
This commit is contained in:
parent
4d7fcf585a
commit
be1b524396
1 changed files with 6 additions and 1 deletions
|
@ -475,11 +475,16 @@ fn render_into(
|
||||||
Conditional { key, children } => {
|
Conditional { key, children } => {
|
||||||
if context.evaluate_conditional(key.as_str(), false)? {
|
if context.evaluate_conditional(key.as_str(), false)? {
|
||||||
render_into(rendered_nodes, children.as_ref(), context, tr)?;
|
render_into(rendered_nodes, children.as_ref(), context, tr)?;
|
||||||
|
} else {
|
||||||
|
// keep checking for errors, but discard rendered nodes
|
||||||
|
render_into(&mut vec![], children.as_ref(), context, tr)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NegatedConditional { key, children } => {
|
NegatedConditional { key, children } => {
|
||||||
if context.evaluate_conditional(key.as_str(), true)? {
|
if context.evaluate_conditional(key.as_str(), true)? {
|
||||||
render_into(rendered_nodes, children.as_ref(), context, tr)?;
|
render_into(rendered_nodes, children.as_ref(), context, tr)?;
|
||||||
|
} else {
|
||||||
|
render_into(&mut vec![], children.as_ref(), context, tr)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1066,7 +1071,7 @@ mod test {
|
||||||
assert_eq!(tmpl.render(&ctx, &tr).unwrap(), vec![]);
|
assert_eq!(tmpl.render(&ctx, &tr).unwrap(), vec![]);
|
||||||
|
|
||||||
// missing
|
// missing
|
||||||
tmpl = PT::from_text("{{^M}}A{{/M}}").unwrap();
|
tmpl = PT::from_text("{{#E}}}{{^M}}A{{/M}}{{/E}}}").unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tmpl.render(&ctx, &tr).unwrap_err(),
|
tmpl.render(&ctx, &tr).unwrap_err(),
|
||||||
TemplateError::NoSuchConditional("^M".to_string())
|
TemplateError::NoSuchConditional("^M".to_string())
|
||||||
|
|
Loading…
Reference in a new issue