Skip to content
New issue

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

html/template: Two panics on executing empty/missing templates #3272

Closed
dsymonds opened this issue Mar 10, 2012 · 1 comment
Closed

html/template: Two panics on executing empty/missing templates #3272

dsymonds opened this issue Mar 10, 2012 · 1 comment
Milestone

Comments

@dsymonds
Copy link
Contributor

Create an empty foo.tmpl file. Execute this code:
----------
package main

import (
        "html/template"
        "log"
        "os"
)

const (
        tmplFile = "foo.tmpl"
)

func main() {
        page := template.Must(template.New("page").ParseFiles(tmplFile))
        data := "bla"
        if err := page.ExecuteTemplate(os.Stdout, "page", data); err != nil {
                log.Print("Failed:", err)
        }
}
----------

The "page" there is a mistake, but the html/template package panics
(html/template internal error: template escaping out of sync) at template.go:68. If you
replace "page" with "foobarbaz" (or anything not naming a template
at all), you get a nil pointer panic at template.go:57.
@robpike
Copy link
Contributor

robpike commented Mar 14, 2012

Comment 1:

This issue was closed by revision 214a1ca.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants