Files
bamort/backend/pdfrender/pagination.go
T
Frank b99adede94 mapping the character data to a viewmodel
that  can be rendered easily into the html template
2025-12-18 21:26:28 +01:00

19 lines
458 B
Go

package pdfrender
// SliceList slices a list based on start index and max items
// Returns the sliced list and whether there are more items
func SliceList[T any](fullList []T, startIndex, maxItems int) ([]T, bool) {
totalCount := len(fullList)
endIndex := startIndex + maxItems
if startIndex >= totalCount {
return []T{}, false
}
if endIndex > totalCount {
endIndex = totalCount
}
return fullList[startIndex:endIndex], endIndex < totalCount
}