golang/go

html/template: default missingkey behavior does not match documentation

Open

#54,053 opened on Jul 25, 2022

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
DocumentationNeedsInvestigationhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

Yes.

What did you do?

https://go.dev/play/p/i3N0a5PATuI

What did you expect to see?

<b><no value></b>

This would align with the documented behavior of Template.Option.

"missingkey=default" or "missingkey=invalid" The default behavior: Do nothing and continue execution. If printed, the result of the index operation is the string "".

This is what text/template outputs.

What did you see instead?

<b></b>

Contributor guide