Skip to content

Commit

Permalink
adds map / slice helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubhang Balkundi committed May 10, 2024
1 parent b0d5709 commit e27cbcd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/tplactions/httpjson/httpjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ func (a *Actions) FuncMap() template.FuncMap {
}
return s, nil
},
"MapGet": func(key string, m map[string]any) any {
return m[key]
},
"SliceGet": func(index int, s []any) any {
n := len(s)
if index < n {
return s[index]
}
return nil
},
}
}

Expand Down

0 comments on commit e27cbcd

Please sign in to comment.