safeJS, safeHTML won't work when tag is inside quotes

Say we have in our head.html file following code:

<meta property="og:description" content="{{ if .IsHome }}{{ site.Params.description | safeHTML }}{{ else }}{{ .Description | safeHTML }}{{ end }}">

and say site’s config.yaml file has:

params:
  description: It is ++, but also < and >

then output is not what one would expect.

I expected:

<meta property="og:description" content="It is ++, but also < and >">

but it was:

<meta property="og:description" content="It is &#43;&#43;, but also &lt; and &gt;">

I also tried htmlUnescape.

Thoughts?

What you want is invalid HTML!
pls read

1 Like