LoveIt/layouts/partials/paginator.html

31 lines
1.3 KiB
HTML
Raw Normal View History

2019-02-03 12:30:44 +01:00
{{ $pag := $.Paginator }}
2019-08-04 15:53:35 +02:00
2019-02-03 12:30:44 +01:00
{{ if gt $pag.TotalPages 1 }}
2019-08-04 15:53:35 +02:00
<ul class="pagination">
{{ with $pag.First }}
{{ end }}
2019-03-15 15:14:53 +01:00
2019-02-03 12:30:44 +01:00
{{ $.Scratch.Set "__paginator.ellipsed" false }}
2019-08-04 15:53:35 +02:00
{{ range $pag.Pagers }}
{{ $right := sub .TotalPages .PageNumber }}
{{ $showNumber := or (le .PageNumber 1) (eq $right 0) }}
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 3)) (lt .PageNumber (add $pag.PageNumber 3))) }}
{{ if $showNumber }}
{{ $.Scratch.Set "__paginator.ellipsed" false }}
{{ $.Scratch.Set "__paginator.shouldEllipse" false }}
{{ else }}
{{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
{{ $.Scratch.Set "__paginator.ellipsed" true }}
{{ end }}
{{ if $showNumber }}
<li class="page-item {{ if eq . $pag }}active{{ end }}">
<span class="page-link">
<a href="{{ .URL }}">{{ .PageNumber }}</a>
</span>
</li>
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }}
<li class="page-item "><span class="page-link" aria-hidden="true">&hellip;</span></li>
{{ end }}
{{ end }}
</ul>
2019-08-18 19:36:52 +02:00
{{ end }}