Omphaloskepsis-2/layouts/partials/reverse-slice.html

10 lines
316 B
HTML
Raw Normal View History

2022-11-11 05:48:02 +00:00
<!-- Source: https://discourse.gohugo.io/t/reverse-array/28753/2 -->
{{- $sliceOriginal := . -}}
{{- $len := len $sliceOriginal -}}
{{- $sliceReversed := slice -}}
{{- range seq $len -}}
{{- $sliceReversed = $sliceReversed | append (index $sliceOriginal (sub $len .)) }}
{{- end -}}
{{- return $sliceReversed -}}