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: doesn't return template on lookup #10910

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

text/template: doesn't return template on lookup #10910

syst3mw0rm opened this issue May 19, 2015 · 5 comments
Assignees
Milestone

Comments

@syst3mw0rm
Copy link
Contributor

@syst3mw0rm syst3mw0rm commented May 19, 2015

package main

import (
    "fmt"
    "text/template"
)

func main() {
    t := template.New("base")
    fmt.Println(t.Lookup("base"))

    t.Parse("{{define \"test\"}}{{end}}")
    fmt.Println(t.Lookup("test"))
    fmt.Println(t.Lookup("base"))
}

returns

<nil>
&{test 0x2083060e0 0x20829c400  }
&{base 0x208306000 0x20829c400  }

on tip b21ff39

First line of output should not be <nil>

@robpike robpike self-assigned this May 20, 2015
@syst3mw0rm
Copy link
Contributor Author

@syst3mw0rm syst3mw0rm commented May 21, 2015

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

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 2, 2015

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

@robpike
Copy link
Contributor

@robpike robpike commented Jun 2, 2015

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

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 2, 2015

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

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

@gopherbot gopherbot commented Jun 3, 2015

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

@mikioh mikioh added this to the Go1.5 milestone Jun 3, 2015
robpike added 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.