-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed as not planned
Closed as not planned
Copy link
Labels
NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Description
The program below prints Master: overlay once, the second prints nothing. And no error. The program is a variation of this example: https://golang.org/pkg/html/template/#example_Template_block -- which is how we do template "inheritance" in Hugo. And judging by the issue reports in this area, adding a BOM marker seems to be a fairly common practice among text editors. I can work around this on my end, but this behavior is very surprising.
https://play.golang.org/p/MQRb5HUk6eH
package main
import (
"fmt"
"log"
"os"
"text/template"
)
func main() {
for _, prefix := range []string{"", "\ufeff"} {
var (
master = `Master: {{block "list" .}}block{{end}}`
overlay = prefix + `{{define "list"}}overlay{{end}}`
)
masterTmpl, err := template.New("master").Parse(master)
if err != nil {
log.Fatal(err)
}
overlayTmpl, err := template.Must(masterTmpl.Clone()).Parse(overlay)
if err != nil {
log.Fatal(err)
}
if err := overlayTmpl.Execute(os.Stdout, ""); err != nil {
log.Fatal(err)
}
fmt.Println()
}
}Metadata
Metadata
Assignees
Labels
NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.