safeHTML removes <strong> from string

Hello all,

I’m getting strings from a json file looking like so:

<p><strong>Ihre Aufgaben:</strong></p>

and loop over it in my template like so:

    {{ range .config.description }}
    <div class="jobad">{{ . | safeHTML }}</div>
    {{ end }}

This works fine but all strong tags are removed from output while the p tags are preserved. Is this default behavior or maybe a matter of configuration?

Thanks

This template code:

{{- $s := slice "<p><strong>Foo</strong></p>" "<p><strong>Bar</strong></p>" -}}
{{- range $s }}
<div>{{ . | safeHTML }}</div>
{{- end -}}

Produces this HTML:

<div><p><strong>Foo</strong></p></div>
<div><p><strong>Bar</strong></p></div>

Take a hard look at what you’re ranging over.

Found the reason :man_facepalming: A matter of selective perception I’m afraid. Thanks for bringing me back on track …

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