Render the else block in sections if the path does not exist or if the path can't be walked.
This fixes all existing compliance tests.
This commit is contained in:
11
src/bin.rs
11
src/bin.rs
@@ -65,11 +65,7 @@ fn read_context_from_stdin() -> serde_json::Value {
|
||||
.read_to_string(&mut buffer)
|
||||
.expect("Failed to read stdin");
|
||||
|
||||
let parsed: serde_json::Value = serde_json::from_str(&buffer).expect("Failed to parse json");
|
||||
match parsed {
|
||||
serde_json::Value::Object(obj) => serde_json::value::Value::Object(obj),
|
||||
_ => panic!("Expected context to be an object"),
|
||||
}
|
||||
serde_json::from_str(&buffer).expect("Failed to parse json")
|
||||
}
|
||||
|
||||
impl ContextElement for serde_json::Value {}
|
||||
@@ -112,7 +108,10 @@ impl Walkable for serde_json::Value {
|
||||
segment: segment.to_string(),
|
||||
elem: self,
|
||||
}),
|
||||
serde_json::Value::Array(_arr) => todo!("Arrays not supported yet"),
|
||||
serde_json::Value::Array(_arr) => Err(RenderError::CantWalk {
|
||||
segment: segment.to_string(),
|
||||
elem: self,
|
||||
}),
|
||||
serde_json::Value::Object(obj) => {
|
||||
obj.get(segment)
|
||||
.map(|val| val as _)
|
||||
|
||||
Reference in New Issue
Block a user