Do a truthiness check on references before printing them.
This commit is contained in:
parent
b45688351e
commit
dedfa79630
@ -99,13 +99,17 @@ impl<'a> DustRenderer<'a> {
|
||||
}
|
||||
DustTag::DTReference(reference) => {
|
||||
let val = walk_path(breadcrumbs, &reference.path.keys);
|
||||
let loop_elements: Vec<&dyn ContextElement> = self.get_loop_elements(val)?;
|
||||
if loop_elements.is_empty() {
|
||||
// if let Err(RenderError::NotFound { .. }) = val {
|
||||
// If reference does not exist in the context, it becomes an empty string
|
||||
return Ok("".to_owned());
|
||||
} else {
|
||||
return val?.render(&reference.filters);
|
||||
match val {
|
||||
Err(RenderError::NotFound { .. }) => return Ok("".to_owned()),
|
||||
Ok(final_val) => {
|
||||
let loop_elements = final_val.get_loop_elements()?;
|
||||
if loop_elements.is_empty() {
|
||||
return Ok("".to_owned());
|
||||
} else {
|
||||
return final_val.render(&reference.filters);
|
||||
}
|
||||
}
|
||||
Err(render_error) => return Err(render_error),
|
||||
}
|
||||
}
|
||||
DustTag::DTSection(container) => {
|
||||
|
Loading…
Reference in New Issue
Block a user