Recently (I am on v0.146.4 now) a partial that consists of SVG code is printed as code and not as an image. Is there anything I can do to make Hugo not encode the output of the partial? Everything seems to be run through htmlEscape
.
If that is expected behaviour, I can catch the output with a return
and unescape myself, but this is one of the things that has worked before. It would be interesting to know if that is based on security settings for not being HTML.
v0.145.0
v0.146.4
Loading the partial
<picture>
{{- $options := dict -}}
{{- if collections.IsSet $package "version" }}
{{- $options = dict
"type" "page"
"tagline" page.Params.sectiontitle
"title" (.LinkTitle | strings.ToUpper)
"subtitle" (fmt.Printf "v%s" $package.version) -}}
{{- else -}}
{{- $options = dict
"type" "page"
"tagline" page.Params.sectiontitle
"title" (.LinkTitle | strings.ToUpper) -}}
{{- end -}}
{{- partials.Include "pages/documentation/headerimage.svg" $options $options -}}
</picture>
The partial
{{- $type := .type | compare.Default "ogimage" -}}
{{- $viewbox := "0 0 1280 640" -}}
{{- $width := 1280 -}}
{{- $height := 640 -}}
{{- $subtractor := 0 -}}
{{- if compare.Eq $type "page" -}}
{{- $viewbox = "0 0 1280 320" -}}
{{- $height = 320 -}}
{{- $subtractor = 320 -}}
{{- end -}}
<svg version="1.1" viewBox="{{- $viewbox -}}"
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<rect width="1280" height="{{- $height -}}" fill="#00000044" />
<text x="20" y="{{ math.Sub 510 $subtractor }}">
{{- with page.Params.sectiontitle -}}
<tspan fill="#dc322f" font-size="42px">
{{- . -}}
</tspan>
{{- end -}}
</text>
<text x="20" y="{{ math.Sub 600 $subtractor }}">
<tspan fill="#dc322f">
<tspan font-size="90px" style="font-family:Changa;">
{{- if (collections.IsSet . "title") -}}
{{- .title -}}
{{- end -}}
{{- if (collections.IsSet . "subtitle") -}}
<tspan font-size="50px" style="font-family:Changa;">
{{- fmt.Printf " %s" .subtitle -}}
</tspan>
{{- end -}}
</tspan>
</tspan>
</text>
</svg>