Have greater than helper very close to correct. Just need to make it compare arrays of scalars.
This commit is contained in:
parent
48e35c54bb
commit
6758d515f1
@ -17,3 +17,18 @@ greater than or equals to
|
|||||||
All comparisons between non-matching types (for example, int vs string) appear to render the main block.
|
All comparisons between non-matching types (for example, int vs string) appear to render the main block.
|
||||||
|
|
||||||
Comparisons between non-scalar types (like arrays) appears to render the main block
|
Comparisons between non-scalar types (like arrays) appears to render the main block
|
||||||
|
|
||||||
|
less than
|
||||||
|
---------
|
||||||
|
|
||||||
|
All comparisons between non-matching types (for example, int vs string) appear to render the else block.
|
||||||
|
|
||||||
|
Comparisons between non-scalar types (like arrays) appears to render the else block
|
||||||
|
|
||||||
|
|
||||||
|
less than or equal to
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
All comparisons between non-matching types (for example, int vs string) appear to render the main block.
|
||||||
|
|
||||||
|
Comparisons between non-scalar types (like arrays) appears to render the main block
|
||||||
|
@ -20,7 +20,10 @@ beta is {beta}{~n}
|
|||||||
{@gt key="a" value="]"}"a" is greater than "]"{:else}"a" is less than or equal to "]"{/gt}{~n}
|
{@gt key="a" value="]"}"a" is greater than "]"{:else}"a" is less than or equal to "]"{/gt}{~n}
|
||||||
{@gt key="a" value="A"}"a" is greater than "A"{:else}"a" is less than or equal to "A"{/gt}{~n}
|
{@gt key="a" value="A"}"a" is greater than "A"{:else}"a" is less than or equal to "A"{/gt}{~n}
|
||||||
{@gt key="a" value="}"}"a" is greater than "}"{:else}"a" is less than or equal to "}"{/gt}{~n}
|
{@gt key="a" value="}"}"a" is greater than "}"{:else}"a" is less than or equal to "}"{/gt}{~n}
|
||||||
|
{!
|
||||||
|
Commented out because unicode not working in rust implementation yet
|
||||||
{@gt key="☃" value="☄"}"☃" is greater than "☄"{:else}"☃" is less than or equal to "☄"{/gt}{~n}
|
{@gt key="☃" value="☄"}"☃" is greater than "☄"{:else}"☃" is less than or equal to "☄"{/gt}{~n}
|
||||||
|
!}
|
||||||
{@gt key=true_value value=false_value}true is greater than false{:else}true is less than or equal to false{/gt}{~n}
|
{@gt key=true_value value=false_value}true is greater than false{:else}true is less than or equal to false{/gt}{~n}
|
||||||
{@gt key=array_lower value=array_higher}[3,5,7] is greater than [8,9]{:else}[3,5,7] is less than or equal to [8,9]{/gt}{~n}
|
{@gt key=array_lower value=array_higher}[3,5,7] is greater than [8,9]{:else}[3,5,7] is less than or equal to [8,9]{/gt}{~n}
|
||||||
{@gt key=array_higher value=array_lower}[8,9] is greater than [3,5,7]{:else}[8,9] is less than or equal to [3,5,7]{/gt}{~n}
|
{@gt key=array_higher value=array_lower}[8,9] is greater than [3,5,7]{:else}[8,9] is less than or equal to [3,5,7]{/gt}{~n}
|
||||||
|
@ -340,6 +340,53 @@ impl<'a> DustRenderer<'a> {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|pair: &KVPair<'a>| (pair.key, &pair.value))
|
.map(|pair: &KVPair<'a>| (pair.key, &pair.value))
|
||||||
.collect();
|
.collect();
|
||||||
|
let left_side: Result<&dyn ContextElement, WalkError> = match param_map.get("key") {
|
||||||
|
None => return Ok("".to_owned()),
|
||||||
|
Some(rval) => match rval {
|
||||||
|
RValue::RVString(text) => Ok(text),
|
||||||
|
RValue::RVPath(path) => walk_path(breadcrumbs, &path.keys),
|
||||||
|
RValue::RVPositiveInteger(num) => Ok(num),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let right_side: Result<&dyn ContextElement, WalkError> =
|
||||||
|
match param_map.get("value") {
|
||||||
|
None => Err(WalkError::CantWalk),
|
||||||
|
Some(rval) => match rval {
|
||||||
|
RValue::RVString(text) => Ok(text),
|
||||||
|
RValue::RVPath(path) => walk_path(breadcrumbs, &path.keys),
|
||||||
|
RValue::RVPositiveInteger(num) => Ok(num),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(Ok(left_side_unwrapped), Ok(right_side_unwrapped)) => {
|
||||||
|
if left_side_unwrapped > right_side_unwrapped {
|
||||||
|
match ¶meterized_block.contents {
|
||||||
|
None => return Ok("".to_owned()),
|
||||||
|
Some(body) => {
|
||||||
|
let rendered_content =
|
||||||
|
self.render_body(body, breadcrumbs, blocks)?;
|
||||||
|
return Ok(rendered_content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => (), // TODO: Implement the rest
|
_ => (), // TODO: Implement the rest
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user