Please help me to solve the "post-category" rendering issue

After upgrading my system, I started to notice the “post-category” rendering issue.

The " character is added to the beginning and end of the post-category span and prevents from rendering the HTML.

This is the code fragment responsible for this issue:

            {{- $categories := slice -}}
            {{- range .Params.categories -}}
            {{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
            {{- $categories = $categories | append (printf `<a href="%v"><i class="svg-icon icon-folder"></i>%v</a>` $category.RelPermalink $category.Title) -}}
            {{- end -}}
            {{- with delimit $categories "&nbsp;" -}}
            <span class="post-category">
                {{ . }}
            </span>
            {{- end -}}

Any help is very much appreciated!

With v0.120.0 and later, the delimit function returns a string instead of template.HTML. This was an intentional breaking change.

You need to pass the result through the safeHTML function. Something like:

{{- with delimit $categories "&nbsp;" -}}
  <span class="post-category">
    {{ . | safeHTML }}
  </span>
{{- end -}}
1 Like

Thank you so much!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.