Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'

This commit is contained in:
Bjørn Erik Pedersen
2023-12-04 15:24:01 +01:00
810 changed files with 24147 additions and 7766 deletions

View File

@@ -1,20 +1,15 @@
---
title: collections.Last
linkTitle: last
description: Slices an array to the last N elements.
categories: [functions]
description: Returns the given collection, limited to the last N elements.
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [last]
related:
- functions/collections/After
- functions/collections/First
returnType: any
signatures: [collections.Last INDEX COLLECTION]
relatedFunctions:
- collections.After
- collections.First
- collections.Last
signatures: [collections.Last N COLLECTION]
aliases: [/functions/last]
---
@@ -23,3 +18,17 @@ aliases: [/functions/last]
{{ .Render "summary" }}
{{ end }}
```
Set `N` to zero to return an empty collection.
```go-html-template
{{ $emptyPageCollection := last 0 .Pages}}
```
Use `last` and [`where`] together.
```go-html-template
{{ range where .Pages "Section" "articles" | last 5 }}
{{ .Render "summary" }}
{{ end }}
```