Initial attempt at implementation, tests not working.
This commit is contained in:
parent
7cde89c601
commit
62cd73f9c9
@ -299,13 +299,13 @@ impl<'a> DustRenderer<'a> {
|
||||
Self::get_rval(breadcrumbs, ¶m_map, "value")
|
||||
.unwrap_or(Err(WalkError::CantWalk));
|
||||
match (left_side, right_side) {
|
||||
(Err(_), _) | (_, Err(_)) => match ¶meterized_block.else_contents {
|
||||
None => return Ok("".to_owned()),
|
||||
Some(body) => {
|
||||
let rendered_content = self.render_body(body, breadcrumbs, blocks)?;
|
||||
return Ok(rendered_content);
|
||||
}
|
||||
},
|
||||
(Err(_), _) | (_, Err(_)) => {
|
||||
return self.render_maybe_body(
|
||||
¶meterized_block.else_contents,
|
||||
breadcrumbs,
|
||||
blocks,
|
||||
)
|
||||
}
|
||||
(Ok(left_side_unwrapped), Ok(right_side_unwrapped)) => {
|
||||
if left_side_unwrapped > right_side_unwrapped {
|
||||
return self.render_maybe_body(
|
||||
@ -323,6 +323,42 @@ impl<'a> DustRenderer<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
DustTag::DTHelperGreaterThenOrEquals(parameterized_block) => {
|
||||
let param_map: HashMap<&str, &RValue<'a>> =
|
||||
Self::get_rval_map(¶meterized_block.params);
|
||||
let left_side: Result<&dyn ContextElement, WalkError> =
|
||||
match Self::get_rval(breadcrumbs, ¶m_map, "key") {
|
||||
None => return Ok("".to_owned()),
|
||||
Some(res) => res,
|
||||
};
|
||||
let right_side: Result<&dyn ContextElement, WalkError> =
|
||||
Self::get_rval(breadcrumbs, ¶m_map, "value")
|
||||
.unwrap_or(Err(WalkError::CantWalk));
|
||||
match (left_side, right_side) {
|
||||
(Err(_), _) | (_, Err(_)) => {
|
||||
return self.render_maybe_body(
|
||||
¶meterized_block.contents,
|
||||
breadcrumbs,
|
||||
blocks,
|
||||
)
|
||||
}
|
||||
(Ok(left_side_unwrapped), Ok(right_side_unwrapped)) => {
|
||||
if left_side_unwrapped >= right_side_unwrapped {
|
||||
return self.render_maybe_body(
|
||||
¶meterized_block.contents,
|
||||
breadcrumbs,
|
||||
blocks,
|
||||
);
|
||||
} else {
|
||||
return self.render_maybe_body(
|
||||
¶meterized_block.else_contents,
|
||||
breadcrumbs,
|
||||
blocks,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => (), // TODO: Implement the rest
|
||||
}
|
||||
Ok("".to_owned())
|
||||
|
Loading…
Reference in New Issue
Block a user