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: ParseFiles confusion with same base name #8464

Closed
gopherbot opened this issue Aug 2, 2014 · 2 comments
Closed

html/template: ParseFiles confusion with same base name #8464

gopherbot opened this issue Aug 2, 2014 · 2 comments

Comments

@gopherbot
Copy link

by nacho4d:

What does 'go version' print?
go version go1.3 darwin/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

template.ParseFiles("tmpl/view.html", "view.html")
"html/template"'s package ParseFiles function will attempt to associate both
files with the same name "view.html". Both files are different contents,
different paths, they should both be available for later execution
See: http://play.golang.org/p/3ZTfkfbYlm

What happened?
The program panics. I am not able to define different templates with the same file name,
even if they are in completely different locations
See: http://play.golang.org/p/3ZTfkfbYlm

What should have happened instead?
Both files should be available, no panics

Please provide any additional information below.
If no one is assigned yet, I would be glad to make a fix :)
@ianlancetaylor
Copy link
Contributor

Comment 1:

I think this is working as intended.  The definition of ParseFiles says that the
template is named for the base name of the first file.  If you want to be able to handle
multiple templates with the same base name, don't use ParseFiles.  I don't see how we
can change this behaviour without breaking the backward compatibility guarantee.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 2 by nacho4d:

I see. I wish there was such a convenience function like ParseFiles but for my case.
I am not 100% sure yet but are you suggesting AddParseTree should be used in this case?

@golang golang locked and limited conversation to collaborators Jun 25, 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

2 participants