From 2469bfc0678b75e16e466cc73b7761b1eb27658d Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 3 Oct 2018 19:51:55 -0600 Subject: [PATCH] feat(for-block): Support iterating on Object Not the fastest implementation but it will do for now. Fixes #201 --- src/tags/for_block.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tags/for_block.rs b/src/tags/for_block.rs index 88d74a8cf..b3440c93f 100644 --- a/src/tags/for_block.rs +++ b/src/tags/for_block.rs @@ -74,6 +74,14 @@ fn get_array(context: &Context, array_id: &Argument) -> Result> { let array = array_id.evaluate(context)?; match array { Value::Array(x) => Ok(x), + Value::Object(x) => { + let x = x + .iter() + .map(|(k, v)| { + Value::Array(vec![Value::scalar(k.as_ref().to_owned()), v.to_owned()]) + }).collect(); + Ok(x) + } x => Err(unexpected_value_error("array", Some(x.type_name()))), } }