From be1b5243968bfe54cf83505648614fa354e117ec Mon Sep 17 00:00:00 2001 From: RumovZ Date: Wed, 28 Jul 2021 12:13:14 +0200 Subject: [PATCH] Find template errors hidden by conditionals --- rslib/src/template.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rslib/src/template.rs b/rslib/src/template.rs index 508e4b9f1..628bf1c26 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -475,11 +475,16 @@ fn render_into( Conditional { key, children } => { if context.evaluate_conditional(key.as_str(), false)? { 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 } => { if context.evaluate_conditional(key.as_str(), true)? { 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![]); // missing - tmpl = PT::from_text("{{^M}}A{{/M}}").unwrap(); + tmpl = PT::from_text("{{#E}}}{{^M}}A{{/M}}{{/E}}}").unwrap(); assert_eq!( tmpl.render(&ctx, &tr).unwrap_err(), TemplateError::NoSuchConditional("^M".to_string())