Skip to content

Commit

Permalink
for over a map iterates over its keys
Browse files Browse the repository at this point in the history
  • Loading branch information
osteele committed Jul 2, 2017
1 parent 8f148dc commit decd8dd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tags/loop.go
Expand Up @@ -44,7 +44,16 @@ func loopTagParser(node chunks.ASTControlTag) (func(io.Writer, chunks.RenderCont
}
loop := val.(*expressions.Loop)
rt := reflect.ValueOf(loop.Expr)
if rt.Kind() != reflect.Array && rt.Kind() != reflect.Slice {
switch rt.Kind() {
case reflect.Map:
array := make([]interface{}, 0, rt.Len())
for _, k := range rt.MapKeys() {
array = append(array, k.Interface())
}
rt = reflect.ValueOf(array)
case reflect.Array, reflect.Slice:
// proceed
default:
return nil
}
if loop.Offset > 0 {
Expand Down

0 comments on commit decd8dd

Please sign in to comment.