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: does not call .String method for formatting #3073

Closed
the42 opened this issue Feb 19, 2012 · 5 comments
Closed

html/template: does not call .String method for formatting #3073

the42 opened this issue Feb 19, 2012 · 5 comments
Milestone

Comments

@the42
Copy link

the42 commented Feb 19, 2012

What steps will reproduce the problem?
1. go run issue.go

What is the expected output?

test/ test/ test/
test/ test/ test/
<a href="test/"> - 1 - </a><a href="test/"> - 2 -
</a><a href="test/"> -3 - </a>

What do you see instead?
test/ test/ test/
<a href="%7b%20%20%3cnil%3e%20%20test/%20%20%7d>"> - 1 -
</a><a href="test/"> - 2 - </a><a
href="test/"> -3 - </a>

Which compiler are you using (5g, 6g, 8g, gccgo)?
go version weekly.2012-02-14 +43cf9b39b647


Which operating system are you using?
uname -a:
Linux ubuntu 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012 x86_64 x86_64
x86_64 GNU/Linux

Which revision are you using?  (hg identify)


Please provide any additional information below.

Attachments:

  1. issue.go (534 bytes)
@robpike
Copy link
Contributor

robpike commented Feb 19, 2012

Comment 1:

There's a spurious angle bracket inside the first element of htmlstr, but I don't think
it's the issue.

Labels changed: added priority-go1, go1-must, removed priority-triage.

Owner changed to builder@golang.org.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Feb 19, 2012

Comment 2:

Shorter example:
package main
import (
    "log"
    "net/url"
    "html/template"
    "os"
)
func main() {
        u, _ := url.Parse("test/")
        if err := template.Must(template.New("x").Parse("{{.}}\n")).Execute(os.Stdout, u); err != nil {
        log.Fatal(err)
    }
}
prints
{  <nil>  test/  }
should print
test/
It is, for some reason, not calling u's String method.

@dsymonds
Copy link
Contributor

Comment 4:

This is something unique to html/template; changing the import to text/template in rsc's
example results in the expected output.

@robpike
Copy link
Contributor

robpike commented Feb 19, 2012

Comment 5:

That may be why the subject is "html/template: ..." :)

@robpike
Copy link
Contributor

robpike commented Feb 20, 2012

Comment 6:

This issue was closed by revision 0ce6c87.

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

5 participants