Partial bug rendering dynamic HTML element name

I have a partial where I want to render a tag based on a parameter value:

<{{ .tag | safeHTML }} class="{{.class}}">

...

</{{ .tag | safeHTML }}>

I call the partial with (dict "tag" "div") say.

The renderer is escaping this as literal text, so it renders the letters <div class="foo"> rather than rendering an actual div tag. Same thing with the closing tag.

It works if I do this instead:

{{ printf "<%s" .tag | safeHTML }} ...

So there is something hooky going on with < or </ next to dynamic content, even when it is marked as safe.

This is the expected behavior. You must mark the entire string as safe, not just the bits inside.