mirror of
https://github.com/Vimux/Binario.git
synced 2024-11-11 01:38:28 +00:00
Pagination: avoid .Scratch function
This commit is contained in:
parent
64780c1741
commit
6dc14f2df3
1 changed files with 7 additions and 6 deletions
|
@ -1,17 +1,18 @@
|
||||||
{{- $pag := $.Paginator }}
|
{{- $pag := $.Paginator }}
|
||||||
{{- if gt $pag.TotalPages 1 }}
|
{{- if gt $pag.TotalPages 1 }}
|
||||||
<div class="pagination block">
|
<div class="pagination block">
|
||||||
{{- $.Scratch.Set "__paginator.ellipsed" false }}
|
{{- $ellipsed := false }}
|
||||||
|
{{- $shouldEllipse := false }}
|
||||||
{{- range $pag.Pagers }}
|
{{- range $pag.Pagers }}
|
||||||
{{- $right := sub .TotalPages .PageNumber }}
|
{{- $right := sub .TotalPages .PageNumber }}
|
||||||
{{- $showNumber := or (le .PageNumber 3) (eq $right 0) }}
|
{{- $showNumber := or (le .PageNumber 3) (eq $right 0) }}
|
||||||
{{- $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
|
{{- $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
|
||||||
{{- if $showNumber }}
|
{{- if $showNumber }}
|
||||||
{{- $.Scratch.Set "__paginator.ellipsed" false }}
|
{{- $ellipsed = false }}
|
||||||
{{- $.Scratch.Set "__paginator.shouldEllipse" false }}
|
{{- $shouldEllipse = false }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
|
{{- $shouldEllipse = not $ellipsed }}
|
||||||
{{- $.Scratch.Set "__paginator.ellipsed" true }}
|
{{- $ellipsed = true }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $showNumber }}
|
{{- if $showNumber }}
|
||||||
{{- if eq . $pag }}
|
{{- if eq . $pag }}
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
{{- else }}
|
{{- else }}
|
||||||
<a class="pagination__item pagination__item--desktop" href="{{ .URL }}">{{ .PageNumber }}</a>
|
<a class="pagination__item pagination__item--desktop" href="{{ .URL }}">{{ .PageNumber }}</a>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else if ($.Scratch.Get "__paginator.shouldEllipse") }}
|
{{- else if $shouldEllipse }}
|
||||||
<span class="pagination__item pagination__item--gap">…</span>
|
<span class="pagination__item pagination__item--gap">…</span>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Reference in a new issue