Skip to content

Commit 30646d3

Browse files
authored
Merge pull request #203 from epage/for
feat(for-block): Support iterating on Object
2 parents eb1fb68 + 2469bfc commit 30646d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/tags/for_block.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ fn get_array(context: &Context, array_id: &Argument) -> Result<Vec<Value>> {
7474
let array = array_id.evaluate(context)?;
7575
match array {
7676
Value::Array(x) => Ok(x),
77+
Value::Object(x) => {
78+
let x = x
79+
.iter()
80+
.map(|(k, v)| {
81+
Value::Array(vec![Value::scalar(k.as_ref().to_owned()), v.to_owned()])
82+
}).collect();
83+
Ok(x)
84+
}
7785
x => Err(unexpected_value_error("array", Some(x.type_name()))),
7886
}
7987
}

0 commit comments

Comments
 (0)