@@ -142,10 +142,10 @@ function walk (opts, nodes) {
142142
143143 if ( Array . isArray ( target ) ) {
144144 for ( let index = 0 ; index < target . length ; index ++ ) {
145- const item = target [ index ]
146- // add item and optional index loop locals
145+ const value = target [ index ]
146+ // add value and optional index loop locals
147147 const scopedLocals = { }
148- scopedLocals [ loopParams . keys [ 0 ] ] = item
148+ scopedLocals [ loopParams . keys [ 0 ] ] = value
149149 if ( loopParams . keys [ 1 ] ) scopedLocals [ loopParams . keys [ 1 ] ] = index
150150 // merge nondestructively into existing locals
151151 const scopedOptions = merge ( opts , { locals : scopedLocals } )
@@ -158,7 +158,22 @@ function walk (opts, nodes) {
158158 }
159159 return m
160160 } else {
161- // object loop
161+ for ( let key in target ) {
162+ const value = target [ key ]
163+ // add item and optional index loop locals
164+ const scopedLocals = { }
165+ scopedLocals [ loopParams . keys [ 0 ] ] = key
166+ if ( loopParams . keys [ 1 ] ) scopedLocals [ loopParams . keys [ 1 ] ] = value
167+ // merge nondestructively into existing locals
168+ const scopedOptions = merge ( opts , { locals : scopedLocals } )
169+ // provide the modified options to the content evaluation
170+ // we need to clone the node because the normal operation modifies
171+ // the node directly
172+ const content = cloneDeep ( node . content )
173+ const res = walk ( scopedOptions , content )
174+ m . push ( res )
175+ }
176+ return m
162177 }
163178 }
164179
0 commit comments