We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version devel go1.24-b2f3a427dd Fri Aug 23 00:53:47 2024 +0000 darwin/arm64
go env
GO111MODULE='on' GOARCH='arm64' GOBIN='' GOCACHE='/Users/xxxx/Library/Caches/go-build' GOENV='/Users/xxxx/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/xxxx/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/xxxx/go' GOPRIVATE='' GOPROXY='' GOROOT='/Users/xxxx/go' GOSUMDB='off' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/Users/xxxx/go/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='devel go1.24-b2f3a427dd Fri Aug 23 00:53:47 2024 +0000' GODEBUG='' GOTELEMETRY='local' GOTELEMETRYDIR='/Users/xxxx/Library/Application Support/go/telemetry' GCCGO='gccgo' GOARM64='v8.0' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='0' GOMOD='/dev/null' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/9t/839s3jmj73bcgyp5x_xh3gw00000gn/T/go-build550188458=/tmp/go-build -gno-record-gcc-switches -fno-common'
Execute the following code:
https://go.dev/play/p/RYn3g_NWx_J
package main import ( "fmt" "html/template" "os" ) type Item struct { X, Y, Z bool Name string } func main() { tmpl := template.Must(template.New("test").Parse(` {{range $index, $item := .Items}} Item {{$index}}: {{$item.Name}} {{if $item.X}}{{break}}{{end}} <a {{if $item.Y}}{{continue}}{{end}} > {{if $item.Z}}{{continue}}{{end}} {{$item.Name}} </a> {{end}} `)) data := struct { Items []Item }{ Items: []Item{ {X: false, Y: false, Z: false, Name: "First"}, {X: false, Y: true, Z: false, Name: "Second"}, {X: false, Y: false, Z: true, Name: "Third"}, {X: true, Y: false, Z: false, Name: "Fourth"}, {X: false, Y: false, Z: false, Name: "Fifth"}, }, } fmt.Println("Template output:") err := tmpl.Execute(os.Stdout, data) if err != nil { fmt.Println("Error:", err) } }
The following code will not throw an error, but will output incomplete HTML content:
Template output: Item 0: First <a > First </a> Item 1: Second <a Item 2: Third <a > Item 3: Fourth
Throwing an error.
The text was updated successfully, but these errors were encountered:
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Sorry, something went wrong.
Change https://go.dev/cl/607736 mentions this issue: html/template: fix the issue of incomplete HTML output due to incorrect append values
html/template: fix the issue of incomplete HTML output due to incorrect append values
7b4ecaa
No branches or pull requests
Go version
go version devel go1.24-b2f3a427dd Fri Aug 23 00:53:47 2024 +0000 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Execute the following code:
https://go.dev/play/p/RYn3g_NWx_J
What did you see happen?
The following code will not throw an error, but will output incomplete HTML content:
What did you expect to see?
Throwing an error.
The text was updated successfully, but these errors were encountered: