Transition to new literals compiling.

Tests still need work, as does the implementation for json.
This commit is contained in:
Tom Alexander
2020-05-16 22:30:04 -04:00
parent bc25c1ee16
commit c905e705ff
5 changed files with 21 additions and 126 deletions

View File

@@ -2,6 +2,7 @@ extern crate nom;
use crate::renderer::CompareContextElement;
use parser::Filter;
use parser::OwnedLiteral;
use renderer::compile_template;
use renderer::CompiledTemplate;
use renderer::ContextElement;
@@ -169,13 +170,13 @@ impl CompareContextElement for serde_json::Value {
}
fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering> {
println!("partial_compare json {:?} | {:?}", self, other);
// println!("partial_compare json {:?} | {:?}", self, other);
// Handle type coerced objects
// When doing a greater than or less than comparison,
// javascript coerces objects into "[object Object]".
if let serde_json::Value::Object(_) = self {
return "[object Object]".to_owned().partial_compare(other);
return OwnedLiteral::LString("[object Object]".to_owned()).partial_compare(other);
}
// Handle other serde_json::Value