{{ $scratch := newScratch }} {{ range $index, $item := .Site.Data.events.items }} {{$t := time .expire_date }} {{ if $t.After now }} {{ $scratch.SetInMap "events" (string $index) $item }} {{ end }} {{ end }} {{ if and (isset .Site.Params "show_events") (eq .Site.Params.show_events true) (ne ($scratch.GetSortedMapValues "events") nil) }}