Can't define variable inside .IsPage block

I’m unable to define a variable inside of an {{ .IsPage }} block with Hugo v0.13.

The following works, and outputs the string ‘yes’:

{{ if .IsPage }}yes{{ end}}

The following do not work:

{{ if .IsPage }}{{ $section := 'yes' }}{{ end }}
{{ if .IsPage }}{{ $section := .Section }}{{ end }}
{{ $section }}

ERROR: 2015/05/04 template partials/sidebar.html:30: undefined variable "$section"

This is a limitation of the Go templates, see

A current workaround is to use the new .Scratch func introduced in Hugo 0.13: