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

text/template: t.New() doesn't save entry in t.tmpl #10926

Closed
syst3mw0rm opened this issue May 21, 2015 · 5 comments
Closed

text/template: t.New() doesn't save entry in t.tmpl #10926

syst3mw0rm opened this issue May 21, 2015 · 5 comments
Milestone

Comments

@syst3mw0rm
Copy link
Contributor

package main

import (
        "fmt"
        "text/template"
)

func main() {
        t, _ := template.New("base").Parse(`{{define "foo"}}foo{{end}}`)
        fmt.Println(t.Lookup("base"))
        fmt.Println(t.Lookup("foo"))

        t.New("bar")
        fmt.Println(t.Lookup("bar"))
}

returns

&{base 0x208304000 0x20829c400  }
&{foo 0x2083040e0 0x20829c400  }
<nil>

on commit 5b66e5d

Last line of output should not be <nil>

@syst3mw0rm
Copy link
Contributor Author

@robpike I've the fix ready, I'll push the CL once you merge https://go-review.googlesource.com/#/c/10240/

@gopherbot
Copy link

CL https://golang.org/cl/10607 mentions this issue.

@robpike
Copy link
Contributor

robpike commented Jun 2, 2015

Working as intended. There is no definition yet, just a name. This is a documentation issue.

@gopherbot
Copy link

CL https://golang.org/cl/10641 mentions this issue.

@robpike robpike closed this as completed in f9ed2f7 Jun 2, 2015
@gopherbot
Copy link

CL https://golang.org/cl/10622 mentions this issue.

@mikioh mikioh added this to the Go1.5 milestone Jun 3, 2015
robpike pushed a commit that referenced this issue Jun 3, 2015
…emplates

This is follow-up to CL10607

- Refactor AddParseTree() to use t.associate()
- Refactor Parse() to use AddParseTree() to put entries into common structure
- Clone() should not put entry in t.tmpl for undefined template
- Clarify documentation for Templates()
- Clarify documentation for AddParseTree() to include the error case

Updates #10910
Uodates #10926

Includes test cases for most of the above changes

Change-Id: I25b2fce6f9651272866f881acf44e4dbca04a4a8
Reviewed-on: https://go-review.googlesource.com/10622
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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