-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Closed
Copy link
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Description
E.g.
package main
import (
"os"
"text/template"
)
func main() {
t := `{{ break 32 }}`
echo := func(in any) any {
return in
}
funcs := template.FuncMap{
"break": echo,
}
tmpl, err := template.New("test").Funcs(funcs).Parse(t)
if err != nil {
panic(err)
}
err = tmpl.Execute(os.Stdout, nil)
if err != nil {
panic(err)
}
}
Note that the above program is a little constructed; I, personally, am not concerned about break/continue. But I notice that the upcoming new return
keyword (#53015) uses the same approach. And an app I'm maintaining (Hugo) does have a return
template func.
Go 1.18:
go1.18 run main.go
32
Go 1.19.3:
go version && go run main.go
go version go1.19.3 darwin/arm64
panic: template: test:1: unexpected "32" in {{break}}
goroutine 1 [running]:
main.main()
/Users/bep/dev/go/bep/temp/main.go:24 +0x258
exit status 2
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.