Error in Shortcode since 0.72

This shortcode runs fine until hugo 0.72:

{{ if eq (.Get "align") "left" }}
    <figure class="figure {{ if ne (.Get "flat") "true" }}card shadow-sm {{ end }}w-100 mb-4 float-lg-left w-lg-50 mr-lg-4 text-center">
{{ else if eq (.Get "align") "right" }}
    <figure class="figure {{ if ne (.Get "flat") "true" }}card shadow-sm {{ end }}w-100 mb-4 float-lg-right w-lg-50 ml-lg-4 text-center">
{{ else }}
    <figure class="figure {{ if ne (.Get "flat") "true" }}card shadow-sm {{ end }}w-100 mb-4 text-center">
{{ end }}
    {{ with .Get "link" }}<a href="{{ . }}">{{ end }}<img src="{{ .Get "src" }}" style="{{ with .Get "height" }}height: {{ . }} !important; {{ end }}{{ with .Get "width" }}width: {{ . }} !important; {{ end }}" {{ with .Get "alt" }}alt="{{ . }}" {{ end }}{{ with .Get "title" }}title="{{ . }}" {{ end }}class="card-img-top figure-img img-fluid" />{{ if .Get "link"}}</a>{{ end }}
    {{ if or ((.Get "caption") (.Get "attr")) }}
        <figcaption class="figure-caption card-footer">
            {{ with .Get "caption" }}<div class="text-left">{{ . | markdownify }}{{ end }}</div>
            {{ if .Get "attr" }}<div class="text-right font-italic">Quelle: {{ with .Get "attrlink"}}<a href="{{ . }}">{{ end }}{{ .Get "attr" }}{{ if .Get "attrlink"}}</a>{{ end }}</div>{{ end }}
        </figcaption>
    {{ end }}
</figure>

The error reads:

Error: Error building site: "/home/juh/Projekte/foo/content/blog/2018/bar.md:23:1": failed to render shortcode "img": failed to process shortcode: "/home/juh/Projekte/foo/layouts/shortcodes/img.html:9:14": execute of template failed: template: shortcodes/img.html:9:14: executing "shortcodes/img.html" at <(.Get "caption") (.Get "attr")>: can't give argument to non-function .Get "caption"

There are not many changes mentioned in the release note of 0.7.2

A suspect might be the Goldmark Typographer thing, but why?

Any hint? Is it a bug or me?

Shouldn’t it be if or (.Get "caption") (.Get "attr") (as in, if caption is available or attr is available)? Don’t know how it was working before.

This throws some other errors.

And that is…?

It just silently failed in earlier versions. This was a bug fix in Go templates.

1 Like