{{- $paginator := .paginator -}} {{- $base := .base | default "/" -}} {{- $current := $paginator.PageNumber -}} {{- $total := $paginator.TotalPages -}} {{- if ge $total 2 -}} {{- $split := 2 -}} {{- if lt $total 9 -}}{{- $split = 9 -}} {{- else if lt $current 4 -}}{{- $split = sub 5 $current -}} {{- else if lt (sub $total 4) $current -}}{{- $split = add 5 (sub $current $total) -}} {{- end -}} {{- $from := sub $current $split -}} {{- if lt $from 1 -}}{{- $from = 1 -}}{{- end -}} {{- $to := add $current $split -}} {{- if gt $to $total -}}{{- $to = $total -}}{{- end -}}