Hugo rendering a hash instead of returned value from partial?

I’m building a fairly complex shortcode/partial combo that generates valid Cloudinary URLs and a valid <img> tag with a srcset.

In the shortcode I set a variable called $src to the output of the partial, and then pass it to a template. When calling .src immediately after this in the template, I get the string I expect.

However, when calling .src inside the images src attribute, I get #ZgotmplZ.

// other vars above...
{{ $src := partial "cloudinary.html" (dict "context" $context "image" $image "width" (index $breakpoints.breakpoints 0) "quality" "auto") }}
{{ template "srcset" (dict "context" $context "src" $src "alt" .alt "breakpoints" $breakpoints "sizes" .preset.sizes "quality" $quality) }}
{{ define "srcset" }}
  {{ .src }} // returns etc
  <img src="{{ $src }}" alt="{{ with .alt }}{{ . }}{{ else }}{{ .src }}{{ end }}" // Returns #ZgotmplZ
    {{- if isset . "preset" -}}
      srcset="{{- range .breakpoints.breakpoints }}
        {{ partial "cloudinary.html" (dict "context" $.context "image" $.image "width" . "quality" $.quality) }} {{ . }}px, // Also returns #ZgotmplZ
      {{ end -}}"
      sizes="{{ .sizes | default "100vw" }}"
    {{ end -}}/>
{{ end }}

Any idea what’s going on here?

Discovered that the partial was rendering white-space from the code indents.

I used a regular expression to strip the whitespace in the shortcode and the src’s started working as expected.

Still, this is really weird behaviour.