HUGO

What does the html function do?

I’ve noticed some templates use a | html function. In the docs, there’s information about the safeHTML, safeHTMLattr, htmlEscape, and htmlUnescape functions but I can’t see any documentation for the html function.

What does html do, and in what way is it different from safeHTML?

1 Like

Great - that makes sense.

I would also be intrested in an answer. Did you get one?

There was a reply, but it was deleted, and it may be due to some action of the poster. I’ll ask the mod. If it is unrelated to the answer, I’ll copy and paste here shortly. :slight_smile:

1 Like

And here is the deleted reply.

Note that this was removed due to that user account being deleted for violating our community standards for different reasons and not due to the content of this particular post.

2 Likes

AFAIK html was the original safeHTML

It would seem that this is actually the opposite in that it strips HTML tags from a string. Can we get any confirmation on this?

https://pkg.go.dev/text/template#hdr-Functions

html

Returns the escaped HTML equivalent of the textual
representation of its arguments. This function is unavailable
in html/template, with a few exceptions.

I love the last sentence.

I love the last sentence.

Right, that’s helpful. :wink: