In this code (at https://play.golang.org/p/HVxzsn0_eC)

package main

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

var tmpl = `<?xml version="1.0" ?>
<list>{{range .}}
  <item>{{.}}</item>{{end}}
</list>
`

var items = []string{"one", "two", "three"}

func main() {
    var t, err = template.New("").Parse(tmpl)
    if err == nil {
        err = t.Execute(os.Stdout, items)
    }
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error: %s\n", err)
    }
}

the Execute method escapes the first character ('<' in "<?xml") to be
"&lt;".  This seems wrong to me, both logically and according to the
documentation, which states in the fourth paragraph under Overview for
text/template:

  all text outside actions is copied to the output unchanged.

Templates are assumed to be written by trusted authors, and don't need
sanitizing; only the substitution data needs escaping.

I don't have a github account.  If nobody disagrees that this is a bug,
will someone please file an issue?

Thanks...Marvin

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to