template: add some missing test cases for First

This commit is contained in:
bep
2015-03-18 20:47:10 +01:00
parent b15d0a168f
commit a8bfaba081
2 changed files with 8 additions and 0 deletions

View File

@@ -289,6 +289,11 @@ func indirect(v reflect.Value) (rv reflect.Value, isNil bool) {
// First is exposed to templates, to iterate over the first N items in a
// rangeable list.
func First(limit interface{}, seq interface{}) (interface{}, error) {
if limit == nil || seq == nil {
return nil, errors.New("both limit and seq must be provided")
}
limitv, err := cast.ToIntE(limit)
if err != nil {