Had to manually interpret the partial_cmp output instead of using the built-in operators since gte confusingly returns true for mismatched values.

This commit is contained in:
Tom Alexander 2020-05-16 18:36:47 -04:00
parent 62cd73f9c9
commit 496a5e0ac7
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -14,7 +14,7 @@ use crate::renderer::inline_partial_tree::extract_inline_partials;
use crate::renderer::inline_partial_tree::InlinePartialTreeElement;
use crate::renderer::parameters_context::ParametersContext;
use crate::renderer::walking::walk_path;
use std::collections::HashMap;
use std::{cmp::Ordering, collections::HashMap};
#[derive(Clone, Debug)]
pub struct CompiledTemplate<'a> {
@ -337,25 +337,25 @@ impl<'a> DustRenderer<'a> {
match (left_side, right_side) {
(Err(_), _) | (_, Err(_)) => {
return self.render_maybe_body(
&parameterized_block.contents,
&parameterized_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(
&parameterized_block.contents,
breadcrumbs,
blocks,
);
} else {
return self.render_maybe_body(
return match left_side_unwrapped.partial_cmp(&right_side_unwrapped) {
Some(Ordering::Greater) | Some(Ordering::Equal) | None => self
.render_maybe_body(
&parameterized_block.contents,
breadcrumbs,
blocks,
),
Some(Ordering::Less) => self.render_maybe_body(
&parameterized_block.else_contents,
breadcrumbs,
blocks,
);
}
),
};
}
}
}