collections.First
{{ range first 5 .Pages }}
{{ .Render "summary" }}
{{ end }}
將 N
設為 0 可以返回一個空的集合。
{{ $emptyPageCollection := first 0 .Pages}}
結合 first
與 where
使用。
{{ range where .Pages "Section" "articles" | first 5 }}
{{ .Render "summary" }}
{{ end }}