Rendering a reference appears to do a truthiness check because false renders an empty string despite rendering as "false" in an array element.
This commit is contained in:
@@ -99,7 +99,9 @@ impl<'a> DustRenderer<'a> {
|
||||
}
|
||||
DustTag::DTReference(reference) => {
|
||||
let val = walk_path(breadcrumbs, &reference.path.keys);
|
||||
if let Err(RenderError::NotFound { .. }) = val {
|
||||
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 {
|
||||
@@ -151,6 +153,21 @@ impl<'a> DustRenderer<'a> {
|
||||
};
|
||||
}
|
||||
}
|
||||
DustTag::DTNotExists(container) => {
|
||||
let val = walk_path(breadcrumbs, &container.path.keys);
|
||||
let loop_elements: Vec<&dyn ContextElement> = self.get_loop_elements(val)?;
|
||||
if !loop_elements.is_empty() {
|
||||
return match &container.else_contents {
|
||||
Some(body) => self.render_body(&body, breadcrumbs),
|
||||
None => Ok("".to_owned()),
|
||||
};
|
||||
} else {
|
||||
return match &container.contents {
|
||||
None => Ok("".to_owned()),
|
||||
Some(body) => self.render_body(&body, breadcrumbs),
|
||||
};
|
||||
}
|
||||
}
|
||||
_ => (), // TODO: Implement the rest
|
||||
}
|
||||
Ok("".to_owned())
|
||||
|
||||
Reference in New Issue
Block a user