Change a variable in the parent scope?

Working with:

{{ $start := math.Max 2 (sub .PageNumber (math.Floor (div $slots 2))) }}
...
{{ if lt $start 2 }}
   {{ $start := 2 }}
{{ end }}

{{ $start := 2 }} won’t change $start outside the if block. I suppose this is just how Go Templates work.

So, how should I go about conditionally changing a variable?

Whoa! Go Templates have TWO assignment operators. := initializes and assigns. = changes the value of an initialized variable!