Can't evaluate variable passed to partial

I’m trying to pass a varibale for header height to a partial with an if statement

{{ $header := $.Params.options.header }}
<div class="wrapper">
	{{ if ne $header nil }}
		{{ if or (eq $header "mini") (eq $header "small") }}
			{{ partial "header-small.html" (dict "context" . "headersize" $header)  }} }}
		{{ end }}
		{{ if eq $.Params.options.header "full" }}
			{{ partial "header-full.html" . }}
		{{ end }}
	{{ else }}
		{{ partial "header-small.html" (dict "context" . "headersize" "small") }}
	{{ end }}

Then, in the header I use the following

<div class="page-header page-header-{{ printf "%" .headersize }}">

I checked the forum and this solution has been applied by others, but I am getting an error in the header-small.html partial:

error calling partial: “/Users/brunoamaral/Labs/Digital-Insanity/themes/now-ui/layouts/partials/header-small.html:1:50”: execute of template failed: template: partials/header-small.html:1:50: executing “partials/header-small.html” at <.headersize>: can’t evaluate field headersize in type *hugolib.pageState

What am I missing?

You are missing the full picture. It’s impossible for me to see what the “.” is with just one line of the partial.

The template I was using was single.html and the result of that code was a map with .Page and “headersize”.

I ended up splitting the logic of deciding which header size is used between the single.html and the partial I was calling.