Bodiless math implementation.
This commit is contained in:
parent
241f6c04e4
commit
11096d7ece
@ -656,9 +656,14 @@ impl<'a> DustRenderer<'a> {
|
||||
ParametersContext::new(self, breadcrumbs, ¶meterized_block.params, None);
|
||||
match ¶meterized_block.contents {
|
||||
None => {
|
||||
// TODO: math without body, calculate the value and render it
|
||||
// Calculate the value
|
||||
// Render
|
||||
return self
|
||||
.perform_math_operation(breadcrumbs, ¶m_map)
|
||||
.map(|final_val| {
|
||||
final_val
|
||||
.get_context_element_reference()
|
||||
.render(&Vec::new())
|
||||
})
|
||||
.unwrap_or(Ok("".to_owned()));
|
||||
}
|
||||
Some(_) => {
|
||||
// TODO: math with body, calculate the value and use it like a select block
|
||||
@ -931,7 +936,7 @@ impl<'a> DustRenderer<'a> {
|
||||
/// Performs a math operation (add, subtract, multiply, divide,
|
||||
/// mod, abs, floor, ceil) and returns the result or None if
|
||||
/// nothing should be rendered.
|
||||
fn performance_math_operation(
|
||||
fn perform_math_operation(
|
||||
&'a self,
|
||||
breadcrumbs: &'a Vec<BreadcrumbTreeElement<'a>>,
|
||||
math_parameters: &'a ParametersContext<'a>,
|
||||
@ -959,8 +964,11 @@ impl<'a> DustRenderer<'a> {
|
||||
.map(|ice| ice.get_context_element_reference())
|
||||
});
|
||||
|
||||
match method_rendered.as_str() {
|
||||
"add" => todo!(),
|
||||
return match method_rendered.as_str() {
|
||||
"add" => match (left_side_ce, right_side_ce) {
|
||||
(None, _) | (Some(Err(_)), _) | (_, None) | (_, Some(Err(_))) => None,
|
||||
(Some(Ok(l)), Some(Ok(r))) => l.math_add(r),
|
||||
},
|
||||
"subtract" => todo!(),
|
||||
"multiply" => todo!(),
|
||||
"divide" => todo!(),
|
||||
@ -968,10 +976,8 @@ impl<'a> DustRenderer<'a> {
|
||||
"abs" => todo!(),
|
||||
"floor" => todo!(),
|
||||
"ceil" => todo!(),
|
||||
_ => return None,
|
||||
}
|
||||
|
||||
todo!()
|
||||
_ => None,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user